|
-
Feb 18th, 2006, 02:32 AM
#1
Thread Starter
Member
How to call word document in vb 6
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
-
Feb 18th, 2006, 02:54 AM
#2
Addicted Member
Re: How to call word document in vb 6
so your basically just trying to open the .doc file?why not use the shell command?
-
Feb 18th, 2006, 03:18 AM
#3
Re: How to call word document in vb 6
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
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Feb 18th, 2006, 04:41 AM
#4
Thread Starter
Member
Re: How to call word document in vb 6
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
-
Feb 18th, 2006, 04:47 AM
#5
Re: How to call word document in vb 6
Did you add the code as I have it posted in its entirity?
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Feb 18th, 2006, 05:21 AM
#6
Thread Starter
Member
Re: How to call word document in vb 6
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
-
Feb 18th, 2006, 05:22 AM
#7
Re: How to call word document in vb 6
Can you post your exact code? Is it in a form, module or class etc.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Feb 18th, 2006, 05:28 AM
#8
Thread Starter
Member
Re: How to call word document in vb 6
ya. its working fine. very very thankful to you.
regards
Hiran
-
Feb 18th, 2006, 05:29 AM
#9
Re: How to call word document in vb 6
Glad its working but what was the issue?
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Feb 18th, 2006, 06:49 AM
#10
Thread Starter
Member
Re: How to call word document in vb 6
actually dont know the problem. i have restarted the application and surprised it is working.
hiran
-
Feb 18th, 2006, 01:06 PM
#11
Re: How to call word document in vb 6
Well if your using code like in post #3 then it will still work.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Feb 19th, 2006, 06:12 AM
#12
Thread Starter
Member
Re: How to call word document in vb 6
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
-
Feb 19th, 2006, 07:10 AM
#13
Re: How to call word document in vb 6
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.
Keith
I've been programming with VB for 25 years. Started with VB4 16bit Pro, VB5 Pro, VB6 Pro/Enterprise and now VB3 Pro. But I'm no expert, I'm still learning.
-
Feb 19th, 2006, 10:51 AM
#14
Thread Starter
Member
Re: How to call word document in vb 6
can u please tell me how to regiser html...
regards
Hiran
-
Feb 19th, 2006, 11:48 AM
#15
Re: How to call word document in vb 6
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.
Keith
I've been programming with VB for 25 years. Started with VB4 16bit Pro, VB5 Pro, VB6 Pro/Enterprise and now VB3 Pro. But I'm no expert, I'm still learning.
-
Feb 19th, 2006, 01:36 PM
#16
Re: How to call word document in vb 6
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:".
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
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
|