Results 1 to 10 of 10
  1. #1
    Bronze Lounger
    Join Date
    Jan 2001
    Location
    Melbourne, Australia
    Posts
    1,294
    Thanks
    0
    Thanked 0 Times in 0 Posts

    is there code to run Start>Run (OfficeXP)

    Hi there

    from Word VBA I have code to check if an application is currently open.
    if not then I would like to fire up the app. The application is the Document Management System 'Hummingbird - DMS',

    to open up this app its not as simple as opening up the .exe of the app . as the .exe is not the main executable & is only a component.

    to open up the app using Windows i can open it up via:
    1. If I goto the menu Start> Run - type in'
    %windir%explorer.exe /e,/root,::{4577EA30-A1DF-11D0-BA3E-00A024746296}' > click OK - this works.

    someone mentioned it also works using the command line prompt but i coulnt get it to work?

    does anyone know how i would run Start>Run via code?
    if I the pcs are different operating systems WinNT4.0, Win2000 & WinXP - would the VBA code be different for each o/s?

    many thanks diana

  2. #2
    Uranium Lounger
    Join Date
    Jan 2001
    Location
    South Carolina, USA
    Posts
    7,295
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: is there code to run Start>Run (OfficeXP)

    The Shell statement should do what you want.
    Legare Coleman

  3. #3
    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: is there code to run Start>Run (OfficeXP)

    If the regular Shell command doesn't work, maybe VBScript's Shell.Execute method will work (but it's more work to get up and running).

    Does the program have a shortcut? You could try to "run" the shortcut (making sure to add the .lnk extension which Windows normally hides from you). That might not be any more standard across all those platforms than the command line you posted...

  4. #4
    Bronze Lounger
    Join Date
    Jan 2001
    Location
    Melbourne, Australia
    Posts
    1,294
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: is there code to run Start>Run (OfficeXP)

    when you mean Shell...
    do mean write the line of code as

    Dim RetVal
    RetVal = Shell("%windir%explorer.exe /e,/root,::{4577EA30-A1DF-11D0-BA3E-00A024746296}", 6)

    also

    ive tried the shortcut & I get an error 'invalid procedure or call.

    RetVal = Shell("C:WinntDMS through icon.lnk", 6) 'run

    any ideas?
    diana

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

    Re: is there code to run Start>Run (OfficeXP)

    Does this work?

    ActiveDocument.FollowHyperlink "C:WinntDMS through icon.lnk"

  6. #6
    Bronze Lounger
    Join Date
    Jan 2001
    Location
    Melbourne, Australia
    Posts
    1,294
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: is there code to run Start>Run (OfficeXP)

    hi hans

    nice one.... :-) that works.

    when i use that code i now get the folllowing warning message > if I click on Yes - the result is it opens up the application.

    Although the title bar of the message box reads, ive never seen this Microsoft dialog box before?
    Is this is a Microsoft dialog box? do you know how to clear it?
    or is do you think its a custion dialog box from the DMS application?

    many thanks again
    diana

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

    Re: is there code to run Start>Run (OfficeXP)

    It's a warning from Microsoft. Since following a hyperlink could be dangerous, you get this warning.

    Here is another method. Place the following code at the top of a module, below Option Explicit but above all Subs and Functions:

    Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" ( _
    ByVal hwnd As Long, _
    ByVal lpOperation As String, _
    ByVal lpFile As String, _
    ByVal lpParameters As String, _
    ByVal lpDirectory As String, _
    ByVal nShowCmd As Long) As Long

    Call it like this in your code:

    ShellExecute 0, "Open", "C:WinntDMS through icon.lnk", 0, 0, 6

  8. #8
    Bronze Lounger
    Join Date
    Jan 2001
    Location
    Melbourne, Australia
    Posts
    1,294
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: is there code to run Start>Run (OfficeXP)

    Many thanks Hans that code worked. your the man! :-)

    I need further fine tuning of the code due to - when the line of code opens up the application - the application takes sometime to open up.
    therefore my code already runs & is completed - while the other application is still opening up.
    The result is although Word is open & running - although you cant access and work in Word.

    I was thinking after the line of code...
    ShellExecute 0, "Open", "C:WinntDMS through icon.lnk", 0, 0, 6

    ...add a DoEvents command. do you think its best to add a 'DoEvents'? or another test?
    If I add DoEvents I dont know what to test for/on?

    any suggestions?
    Diana



    '
    ' Check that the file has finished spooling. (as it may be a large doc)
    '
    With Application
    ' Some other statement.... like PrintOut....
    Do While .BackgroundPrintingStatus > 0
    DoEvents
    If .BackgroundPrintingStatus <= 0 Then Exit Do
    Loop
    .ActiveDocument.Activate
    End With

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

    Re: is there code to run Start>Run (OfficeXP)

    DoEvents gives other applications a chance to run, but you cannot use it (reliably) to test. I don't know anything about Hummingbird, so I have no idea how to test. Does it have a window with a predictable title?

  10. #10
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Yilgarn region of Toronto, Ontario
    Posts
    5,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: is there code to run Start>Run (OfficeXP)

    > Does it have a window with a predictable title?

    It may, but I've learned to steer away from titles, if by titles you mean Application.Caption.

    I've been dabbling with the code below. I like sample 1, if I can ever get it to work, because it seems to be asking for an intrinsic part of the application code, rather than a modifiable part, such as the name of the executable.

    Sample 1
    =======
    <pre> ' Get the class name of the parent window:
    r = GetClassName(hWndParent, sParentClassName, 100)
    If Left(sParentClassName, r) = "XLMAIN" Then
    MsgBox Left(sParentClassName, r)
    Else
    End If
    Debug.Print "Parent Window Class Name: "; Left(sParentClassName, r)</pre>



    Sample 2
    =======

    <pre>Private Sub Form_Load()
    Debug.Print TallyPrograms("excel.exe")
    End Sub

    Private Function TallyPrograms(ByRef EXEName As String)
    Dim cmd As String
    cmd = "SELECT * FROM Win32_Process WHERE Name='" & EXEName & "'"
    TallyPrograms = GetObject("winmgmts:").ExecQuery(cmd).Count
    End Function</pre>


Posting Permissions

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