-
I am using shellexecute to launch an excel data file from vb : ret2 = ShellExecute(0&, "OPEN", filename, "", "", 1)
where filename is, for example, "text.xls".
Test.xls is an "!" delimitted text file. The problem is, when excel opens, it bypasses the Text Import Wizard.
I cannot use the Excel object in VB.
2 questions.
1) Once I have a process id (ret2), can I send commands to Excel from VB?
2) Is there anything I can add to the shellexecute command that Excel will recognize so the Import Wizard will show up?
Thanks
-
Use the shell exe API rather than the straight Shell that is available in VB
----------------------------------------------------
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hWnd As Long, ByVal opOperation As String, ByVal lpFile As String, ByVal opParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
' just call it like this ShellExe("Explorer")
Public Sub ShellExe(What As String)
On Error Resume Next
Call ShellExecute(0&, vbNullString, What, vbNullString, vbNullString, vbNormalFocus)
End Sub
-
I'm already using the shellexecute function. What will your code do that mine isn't doing already?
Thanks again.
-
though you might only be using the shell statement that is built into VB.
what happens when you execute the file from the run prompt
c:\text.xls
-------------------------------
ret2 = ShellExecute(0&, "OPEN", filename, "", "", 1)
--------------------------------
try this
ret2 = ShellExecute(0&, vbNullString, filename, "", "", 1)