[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

How do you run a PDF file  from Visual Basic?

Posted on 2009-12-20
1
Medium Priority
?
173 Views
Last Modified: 2012-05-08
I want to run a pdf file from my VB5 program like I do .doc files.  I successfully use,

X = Shell ("write test.doc",1) to open a .doc file

but,

X = Shell("test.pdf",1) does not open the pdf file.
0
Comment
Question by:drleewood
1 Comment
 
LVL 59

Accepted Solution

by:
Chris Bottomley earned 2000 total points
ID: 26091457
Hello drleewood,

Add the shellexecute declaration to the top of the code module, (after option statements if present).  The act of opening a file is captured by the call to the sub.

Regards,

chris_bottomley
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

Sub testOpen()
    ShellExecute 0&, "open", "c:\deleteme\fred.pdf", 0&, 0&, 0&
End Sub

Open in new window

0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses
Course of the Month18 days, 19 hours left to enroll

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question