-
Feb 28th, 2017, 04:20 PM
#1
Thread Starter
Lively Member
[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"
-------------------------------------------------------------------
-
Feb 28th, 2017, 04:32 PM
#2
Hyperactive Member
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
-
Feb 28th, 2017, 04:44 PM
#3
Thread Starter
Lively Member
Re: Shell Office or another App!
Originally Posted by I Love VB6
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
-----------------------------------------------------------------------------------------------------
-
Feb 28th, 2017, 04:53 PM
#4
Hyperactive Member
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.
-
Feb 28th, 2017, 05:00 PM
#5
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.
-
Feb 28th, 2017, 05:14 PM
#6
Thread Starter
Lively Member
Re: Shell Office or another App!
-
Feb 28th, 2017, 05:19 PM
#7
Hyperactive Member
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.
-
Feb 28th, 2017, 05:28 PM
#8
Thread Starter
Lively Member
Re: [RESOLVED] Shell Office or another App!
Originally Posted by I Love VB6
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|