How do I run an Excel macro from a VB 6.0 application?
Posted on 2003-03-12
A friend of mine has asked me to modify his VB6.0 application to enable it to create an
Excel 97 spreadsheet from a text or csv file. I've created a macro in Excel that opens the file.
Here's the question: How do I run the Excel macro from VB? I have tried using a shell command
to start Excel, which it does, but it throws an "object required" error when it gets to the
macro code which I pasted into VB. That code is:
Selection.TextToColumns Destination:=Range("A1"), DataType:= _
xlFixedWidth, FieldInfo:=Array(Array(0, 1), Array(1, 1), Array(6, 1), _
Array(9, 1), Array(14, 1))
The file is where it should be, I'm not sure which object is not being found.Debug highlights
the entire block of code. I've tried the Help files but have not been able to make this work. Any assistance would be greatly appreciated. Sorry about the low point value, I'm new
and not "Premium."