Results 1 to 8 of 8

Thread: [RESOLVED] Shell Office or another App!

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Aug 2016
    Posts
    104

    Resolved [RESOLVED] Shell Office or another App!

    Hi dears

    I want to shell office and i have a code (It works), but my code does not work on another PC because the path and office version (Or MS Office 2003, MS Office 2007, MS Office 2010, . . . ) is different how can I solve it?

    -------------------------------------------------------------------
    Shell "C:\Program Files (x86)\Microsoft Office\Office14\WINWORD.EXE", vbNormalFocus
    -------------------------------------------------------------------
    This code contains my "Office Path"
    -------------------------------------------------------------------

  2. #2
    Hyperactive Member
    Join Date
    Oct 2016
    Posts
    369

    Re: Shell Office or another App!

    Maybe you should use ShellExecute instead of Shell. Usually you don't need the path if the application has been properly installed because Windows keeps the path and when you use ShellExecute with a file name with the correct extension the path is supplied by Windows

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Aug 2016
    Posts
    104

    Re: Shell Office or another App!

    Quote Originally Posted by I Love VB6 View Post
    Maybe you should use ShellExecute instead of Shell. Usually you don't need the path if the application has been properly installed because Windows keeps the path and when you use ShellExecute with a file name with the correct extension the path is supplied by Windows
    I found this But Even in this code I have to find the path
    ------------------------------------------------------
    Option Explicit

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

    Private Sub Form_Load()
    Call ShellExecute(0, StrPtr("Open"), StrPtr(App.Path & "\Test.exe"), 0, 0, 1)
    End Sub
    -----------------------------------------------------------------------------------------------------

  4. #4
    Hyperactive Member
    Join Date
    Oct 2016
    Posts
    369

    Re: Shell Office or another App!

    Try this

    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


    ShellExecute hWnd, "open", "http://www.google.com", vbNullString, vbNullString, 5

    This will launch your default browser.

    For you, change the http part to the name of an existing file that is the output of Winword.exe

    What you are doing is launching your own private application and Windows does not know anything about it. Read my 1st post again; I said Usually you don't need the path if the application has been properly installed and this: when you use ShellExecute with a file name with the correct extension the path is supplied by Windows. Now let that sink into your head, OK

    Also, in your 1st post you said WINWORD.EXE not Test.exe and I responded to your 1st post.
    Last edited by I Love VB6; Feb 28th, 2017 at 05:09 PM.

  5. #5
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    9,145

    Re: Shell Office or another App!

    Or, as you wanted to open an OFFICE file, substitute winword.exe for http://www.google.com.....IF that is what you are wanting to do.

  6. #6

    Thread Starter
    Lively Member
    Join Date
    Aug 2016
    Posts
    104

    Re: Shell Office or another App!

    Thank you It work!

  7. #7
    Hyperactive Member
    Join Date
    Oct 2016
    Posts
    369

    Re: [RESOLVED] Shell Office or another App!

    However, I may have misunderstood you. What I suggested was to open an exe with a file and now I think you only want to open the exe but without a file. In this case, you can just use Shell as long as the exe is a system application, like Notepad.

  8. #8

    Thread Starter
    Lively Member
    Join Date
    Aug 2016
    Posts
    104

    Re: [RESOLVED] Shell Office or another App!

    Quote Originally Posted by I Love VB6 View Post
    However, I may have misunderstood you. What I suggested was to open an exe with a file and now I think you only want to open the exe but without a file. In this case, you can just use Shell as long as the exe is a system application, like Notepad.
    Thank you dear I Love VB6, your post #4 was my desire

Tags for this Thread

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