Archived

This topic is now archived and is closed to further replies.

Want to open a .PDF file from VB (in a shell)

This topic is 4961 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I need to open a PDF file from a VB application I am making. In fact, what it is doing is opening the game manual for the user. Here is the code I have: Res = ShellExecute(Form1.hwnd, "open", "manual.pdf", vbNullString, vbNullString, 0) When I run the code, it begins to execute. The Adobe Acrobat intro screen pops up. But then nothing shows up. I look in Task Manager and I see Acrobat is running under the Processes tab, but I dont see it under the Applications tab. I have verified that the PDF file name and path are correct. I suspect it has something to do with the hWnd parameter. I have tried setting it to 0, but that doesnt work either. Thanks, Brian

Share this post


Link to post
Share on other sites
The last parameter to ShellExecute is ''nShowCmd'', and I''m betting 0 is the value for SW_HIDE. You need to find the value for one of the constants that shows the window (SW_HIDE being the only one that does not) and replace the 0 with that.

Share this post


Link to post
Share on other sites
This works every time.

ShellExecute(Me.hwnd, "Open", "filename.pdf", 0&, 0&, 5)

I don''t know the constant term for the 5, but it will give you a full screen Acrobat Reader. Also, if the return value is <=32, you have an error. The most common error is lack of Adobe Acrobat Reader.

-Kirk

Share this post


Link to post
Share on other sites
Yeah, it was the last parameter. I tried putting "SW_SHOW" in there earlier. However, I am so used to C++ that I didnt realize that SW_SHOW is not declared in VB and won''t give an error since VB allows you to declare variables on the fly... hehe

Thanks,

Brian

Share this post


Link to post
Share on other sites
quote:
Original post by BrianH
However, I am so used to C++ that I didnt realize that SW_SHOW is not declared in VB and won''t give an error since VB allows you to declare variables on the fly... hehe


Option Explicit!! VB is really worthless without it.

Share this post


Link to post
Share on other sites