Results 1 to 8 of 8
  1. #1
    3 Star Lounger
    Join Date
    Aug 2002
    Location
    Denmark
    Posts
    347
    Thanks
    0
    Thanked 0 Times in 0 Posts

    In Excel, run an rundll32.exe + dll with variables ( Excel O'03 - WinXP SP3 - UK)

    Hi,

    Got some code in Excel that retrieves a variable from a database. Subsequently I update the database with a new value and then needs to trigger another update function contained in a DLL. The function requires 2 parameters (eg. 'Ticker' and 'time period'). 'Ticker' are retrieved from the database and time period are always 'DATE'.

    So from within Excel I need to send a line that in a command prompt looks like this:

    'rundll32.exe somedll.dll UpdateFunction Parameter1 Parameter2'

    Typing this directly in a command prompt works fine. From a lot of reading I've seen various suggestions, but haven't been able to find one that does exactly what I
    need...

    My function so far is something like this...

    Function RunUpdate(ByRef Ticker As String) As Boolean
    Dim oShell
    Dim WScript As Object
    Dim Date$

    Date = Date

    Set WScript = CreateObject("WScript.Shell")
    oShell = WScript.Run("cmd /K 'rundll32.exe somedll.dll UpdateFunction Ticker Date",1)
    Debug.Print oShell
    RunUpdate = True

    Set WScript = Nothing

    End Function

    However this function does not update...

    I expect that part of the problem is that the parameters are within the string sent to the command prompt.

    Does anyone know how this is 'normally' achieved?
    (I believe calling an outside dll with variable parameters must be something others do often...)

    THX
    Bests,
    RD


    PS: Wish there were a knob on the TV to turn up the intelligence. There's a knob called "brightness," but that doesn't work

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: In Excel, run an rundll32.exe + dll with variables ( Excel O'03 - WinX

    Try something like

    oShell = WScript.Run("cmd /K 'rundll32.exe somedll.dll UpdateFunction " & Ticker & " " & Date,1)

    BTW I don't think naming a variable Date is a good idea, since Date is also a built-in function.

  3. #3
    3 Star Lounger
    Join Date
    Aug 2002
    Location
    Denmark
    Posts
    347
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: In Excel, run an rundll32.exe + dll with variables ( Excel O'03 - WinX

    Hi Hans,

    Thanks - I'll give it a shot.

    'Date' was actually sToday = Date (don't think I would be allowed to use Date at all. If I remember correctly it is a reserved key word)

    Was typing this part directly in the msgbox - so it was more of a typo, sorry.
    Bests,
    RD


    PS: Wish there were a knob on the TV to turn up the intelligence. There's a knob called "brightness," but that doesn't work

  4. #4
    3 Star Lounger
    Join Date
    Aug 2002
    Location
    Denmark
    Posts
    347
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: In Excel, run an rundll32.exe + dll with variables ( Excel O'03 - WinX

    Another question on the same note...

    I read somewhere that the Wscript or the 'runDLL32' command in case it fails throws a 0 into some sort of a log file and that this error is trappable.

    Unfortunately I don't remember where I saw it and I can't find the article that I read this in...

    Would you by any chance have an idea of what I might be looking for here??

    THX
    Bests,
    RD


    PS: Wish there were a knob on the TV to turn up the intelligence. There's a knob called "brightness," but that doesn't work

  5. #5
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: In Excel, run an rundll32.exe + dll with variables ( Excel O'03 - WinX

    I have no idea; I hope that someone else can help you.

  6. #6
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: In Excel, run an rundll32.exe + dll with variables ( Excel O'03 - WinX

    In the old days of DOS batch files, one could check a value called ERRORLEVEL. Does that sound like something that might be relevant to your application?

  7. #7
    WS Lounge VIP rory's Avatar
    Join Date
    Dec 2000
    Location
    Burwash, East Sussex, United Kingdom
    Posts
    6,280
    Thanks
    3
    Thanked 191 Times in 177 Posts

    Re: In Excel, run an rundll32.exe + dll with variables ( Excel O'03 - Win

    As a matter of interest, have you tried declaring the function in VBA as you would with a Windows API call to see if you can call it directly (it will depend on how the dll was built I think)?
    Regards,
    Rory

    Microsoft MVP - Excel

  8. #8
    3 Star Lounger
    Join Date
    Aug 2002
    Location
    Denmark
    Posts
    347
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: In Excel, run an rundll32.exe + dll with variables ( Excel O'03 - Win

    Have just checked with the provider of the DLL - unfortunately this is not currently possible. Was a nice idea though <img src=/S/grin.gif border=0 alt=grin width=15 height=15>
    Bests,
    RD


    PS: Wish there were a knob on the TV to turn up the intelligence. There's a knob called "brightness," but that doesn't work

Posting Permissions

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