Results 1 to 4 of 4

Thread: ShellExecute Question

  1. #1

    Thread Starter
    New Member
    Join Date
    Jul 1999
    Posts
    13

    Question

    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

  2. #2
    Fanatic Member
    Join Date
    Jul 2000
    Location
    Manchester NH
    Posts
    833
    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
    Kurt Simons
    [I know I'm a hack but my clients don't!]

  3. #3

    Thread Starter
    New Member
    Join Date
    Jul 1999
    Posts
    13
    I'm already using the shellexecute function. What will your code do that mine isn't doing already?

    Thanks again.

  4. #4
    Fanatic Member
    Join Date
    Jul 2000
    Location
    Manchester NH
    Posts
    833
    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)



    Kurt Simons
    [I know I'm a hack but my clients don't!]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width