Hi,
I want to call word document in vb 6. pl suggest how to call.
I have a user manual which is .doc file. In vb menu, if i click on usermanual menu item, document has to be opened. pl help me.
regards
hiran
Printable View
Hi,
I want to call word document in vb 6. pl suggest how to call.
I have a user manual which is .doc file. In vb menu, if i click on usermanual menu item, document has to be opened. pl help me.
regards
hiran
so your basically just trying to open the .doc file?why not use the shell command?
Yes, if your not going to be automating the word document then just shellExecute it.
VB Code:
Option Explicit 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 Const SW_SHOWNORMAL As Long = 1 Private Const SW_SHOWMINIMIZED As Long = 2 Private Const SW_SHOWMAXIMIZED As Long = 3 Private Sub Command1_Click() On Error GoTo MyError Dim lRet As Long lRet = ShellExecute(Me.hwnd, "Open", "C:\UserManual.doc", vbNullString, "C:\", SW_SHOWNORMAL) If lRet <= 32 Then MsgBox "Error Shelling Word" End If Exit Sub MyError: MsgBox Err.Number & " - " & Err.Description End Sub
Hi,
Thanks. But i am still getting problem
I am getting the error like "Sub or Function not defined" pointing on lret=ShellExecute.
Ple help
Regards
Hiran
Did you add the code as I have it posted in its entirity?
yes. same code i have written. just changed the filename. i have checked the shell32.dll also. it is existing in my system.
regards
hiran
Can you post your exact code? Is it in a form, module or class etc.
ya. its working fine. very very thankful to you.
regards
Hiran
Glad its working but what was the issue?
actually dont know the problem. i have restarted the application and surprised it is working.
hiran
Well if your using code like in post #3 then it will still work.
hi,
the code for opening doc file is perfectly working. will this shellexecute works for html files. when i am trying to call html, i am getting the message "Error Shelling Word".
Pl suggest.
regards
ShellExecute will open any file that is registered in the registry. e.g. *.doc, *.xls, *.txt, *.ini, *.chm, *.pdf, *.html ;)
Actually ShellExecute is a useful API, you can open virtually anything, print, send emails etc.
can u please tell me how to regiser html...
regards
Hiran
An html file should already be registered to your browser, IE, FireFox or what ever. Therefore it will use that app to open the html file. ;)
Yes, its like Keithuk is saying but to expand, if a file extension is registered you can easily see its association by right clicking on the file and click Properties. Then it will show in the "Opens with:".