|
-
June 28th, 2001, 05:18 PM
#1
open word
I'm opening Microsoft word from VB 6 application.
i use command
app_path is winword.exe path from registry and trial.doc is in the same directory.
taskId = Shell(app_path & "trial.doc", 1)
error message says "File could not be found.
i use similar code for Acrobat reader and that works fine.
I have one more question,
When another application is opened from VB. How to make that application active window. In my case, sometime it is active and sometime it goes in background. I tried AppActivate, but it does not work.
Any help will be highly appreciated.
-
June 28th, 2001, 06:16 PM
#2
Re: open word
you need to tell Shell what application to execute (WinWord.exe) along with its path then tell Winword where the File is located. Something like this:
'
taskId = Shell(app_path & "\WinWord.exe C:\MyPPath\trial.doc", 1.
'
There are APIs that can determine the filetype and invoke the Windows based on the .dioc extension something like this.
option Explicit
private Const SW_SHOW as Integer = 5
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
private Sub Command1_Click()
Dim lrc
Dim sFilename
sFilename = "C:\my Documents\Record Albums.doc"
lrc = ShellExecute(me.hwnd, "open", sFilename, vbNullString, 0, SW_SHOW)
End Sub
John G
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
|