Click here to Skip to main content
15,792,217 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I can open pdf files from vb6 application in Window XP SP3, but I am unable to open the same from Windows 7, pls help. Thanks in advance
VB
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" _
(ByVal hwnd As Long, ByVal lpszOp As String, _
ByVal lpszFile As String, ByVal lpszParams As String, _
ByVal LpszDir As String, ByVal FsShowCmd As Long) _
As Long
Dim l As Long
'it works in windows XP SP3
l = ShellExecute(Me.hwnd, "Open", App.Path & "\Forms\Form.pdf", "", "C:\ProgramFiles(x86)", vbNormal
Posted
Updated 11-Dec-19 17:42pm
v2
Comments
db7uk 31-May-12 15:00pm    
What is the error you are getting? your program files path looks iffy and are you saying that the Win7 environment is 64bit or 32bit?

"C:\ProgramFiles(x86)" should be "C:\Program Files (x86)". I don't know if that's the source of your problem, but it could be. (There is an environment variable ProgramFiles(x86), but the folder has spaces)
 
Share this answer
 
You should try the following code :

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 Command_Click()
strDir = "<your files="" directory="">"
strFile = "<your filename="">.pdf"
ShellExecute 0, "OPEN", strDir & strFile, "", strDir, 1
End Sub
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900