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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help!!! TexttoColumns

Status
Not open for further replies.

ACTHelp

MIS
Feb 8, 2005
30
US
I'm trying to execute a Texttocolumns command from a vb module in Access against an Excel spreadsheet.

Here's my code:

Sub parsetext()
'
' parsetext Macro
'
Dim strexceltab As String
strexceltab = "excel"
objXLApp.Worksheets(strexceltab).Range("b1").Select
objXLApp.Worksheets(strexceltab).Range("b1").Activate

objXLApp.Selection.EntireColumn.Insert
objXLApp.Selection.EntireColumn.Insert
objXLApp.Selection.EntireColumn.Insert
objXLApp.Selection.EntireColumn.Insert
' Application.CutCopyMode = False
objXLApp.Worksheets(strexceltab).Range("a2:a380").Select
objXLApp.Worksheets(strexceltab).Range("a2:a380").Activate


objXLApp.Selection.TextToColumns.Destination(Range("b1")) _
.DataType(xlDelimited) _
.TextQualifier(xlNone) _
.ConsecutiveDelimiter(False) _
.Tab(False) _
.Semicolon(False) _
.Comma(False) _
.Space(False) _
.Other(True) _
.OtherChar(".") _
.FieldInfo (Array(Array(1, 1), Array(2, 1), Array(3, 1)))

End Sub

The insert of the three columns works fine and the selection of the area prior to the texttocolumns command works fine as well.

The data in the first column contains data such as:

Atlanta.Anderson, Mark - 5501.C8000 INSTRUMENT
Atlanta.Anderson, Mark - 5501.All Instruments
Atlanta.Atlanta.C8000 INSTRUMENT


It is delimited by a period.

I am getting this error:
Error #1004:Application-defined or object_defined error



 
Hi
Do you have a reference to the Excel library?
 
Probably not since I'm not sure. Since all the other Excel stuff is working...thought I was ok.
 
And this ?
objXLApp.Selection.TextToColumns _
Destination:=objXLApp.Range("b1") _
DataType:=xlDelimited _
TextQualifier:=xlNone _
ConsecutiveDelimiter:=False _
Tab:=False _
Semicolon:=False _
Comma:=False _
Space:=False _
Other:=True _
OtherChar:="." _
FieldInfo:=Array(Array(1, 1), Array(2, 1), Array(3, 1))


Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
get a compile error:
objXLApp.Selection.TextToColumns _
Destination:=objXLApp.Range("b1") _
DataType:=xlDelimited _
TextQualifier:=xlNone _
ConsecutiveDelimiter:=False _
Tab:=False _
Semicolon:=False _
Comma:=False _
Space:=False _
Other:=True _
OtherChar:="." _
FieldInfo:=Array(Array(1, 1), Array(2, 1), Array(3, 1))


expected end of statement with DataType highlighted
 
Sorry for the typo:
objXLApp.Selection.TextToColumns _
Destination:=objXLApp.Range("b1"), _
DataType:=xlDelimited, _
TextQualifier:=xlNone, _
ConsecutiveDelimiter:=False, _
Tab:=False, _
Semicolon:=False, _
Comma:=False, _
Space:=False, _
Other:=True, _
OtherChar:=".", _
FieldInfo:=Array(Array(1, 1), Array(2, 1), Array(3, 1))

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Yes...I had already added the commas and it worked! Thanks so much for your help and quick responses!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top