Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VBA Macro Fails to Run

Status
Not open for further replies.

snikde

Programmer
Mar 13, 2002
35
US
I have created this macro and it fails in Word. It will not run and complains about the xlToRight in the insert command and then all the sort functions it complains about too, i.e Range, xlAscending, etc. Yet it works in Excel. Is there some limit to calls made to Excel from other applications via VBA? Whats the fix?


Set xlApp = CreateObject("Excel.Application")

xlApp.Visible = True
xlApp.Workbooks.Add

'xlApp.ActiveSheet.Cells(1, 1).Value = mstrComponentPathNameList
thetest = DxTokenize(mstrComponentPathNameList, Chr(13), DXT_TABS_OK, ListArry())

For i = 1 To UBound(ListArry)
xlApp.ActiveSheet.Cells(i, 1).Value = ListArry(i)

Next i
With xlApp
.Cells.Select
.Selection.ColumnWidth = 77.86
.Selection.RowHeight = 14.25
.Columns("A:A").Select
.Selection.Insert Shift:=xlToRight
.Selection.Sort Key1:=Range("B1"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
.Rows("1:1").Select
.Selection.Delete

End With
 
Do you have a reference set to the Excel library in the VBA Editor? (menu path: Tools/References. . .)

VBAjedi [swords]
 
Oh well I get the stupid pill award for the day!!! Thanks, case solved.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top