Solved

view a pdf file from access form

Posted on 2011-09-15
9
430 Views
Last Modified: 2012-08-13
hello, i use code below to view a word document from access form- is there  a way to view a pdf file in similar way - using command button?
thank you
Private Sub Command0_Click()
Dim WordDoc As String
Dim oApp As Object

If Dir(WordDoc) = "" Then
MsgBox "Not here"
Else
'Create an instance of MS Word
Set oApp = CreateObject(Class:="Word.Application")
oApp.Visible = True
'Open the Document
oApp.Documents.Open FileName:="\\Main\CSA\Excel\documents\TRAINING.docx"
End If

Open in new window

0
Comment
Question by:davetough
  • 4
  • 2
  • 2
  • +1
9 Comments
 
LVL 75

Accepted Solution

by:
DatabaseMX (Joe Anderson - Access MVP) earned 167 total points
ID: 36545890
How about this:

Shell "C:\SomeFolder\YourPdfName.PDF", vbNormalFocus

mx
0
 
LVL 84

Assisted Solution

by:Scott McDaniel (Microsoft Access MVP - EE MVE )
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 167 total points
ID: 36545951
I've had some issues opening PDF files using Shell, even when the .pdf extension is correctly associated with a valid PDF program like Adobe or one of the other readers. In some cases, you'll have actually use syntax like this:

Shell "Full path to Acrobat Reader " &  "Full path to your PDF file"

0
 
LVL 75
ID: 36545975
Humm ... could be.  I just tested what I posted, and the PDF opened with no issue.

mx
0
 
LVL 84
ID: 36546223
It does on my machines as well, but I've had more than one client who could not open a PDF file in this manner. The Shell command works for all other types, but the .pdf extension (for some reason) gives troubles.

That said, I haven't had in troubles in the last few versions of Adobe Reader.
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 21

Assisted Solution

by:Boyd (HiTechCoach) Trimmell, Microsoft Access MVP
Boyd (HiTechCoach) Trimmell, Microsoft Access MVP earned 166 total points
ID: 36546683
I use ShellExec for all types of files. Word, Excel, PDFs etc.

See this example for the code:  Document Links 2


 Note: Some versions of Acrobat reader don't play well with Shel(). ShellExec() seams to always work.
0
 

Author Closing Comment

by:davetough
ID: 36546752
thanks- just a question here- the hitechcoach database code is something- thanks-
databasemx when you suggest Shell "C:\SomeFolder\YourPdfName.PDF", vbNormalFocus
and lsmconsulting pathway to both acrobat and pdf- can i place that code in command button?
everytime i see shell - i think i need to be able to write alot of code like hitechs to make it work- have never used shell- and am wondering if my ignorance of some basics - i should probaly know- making me not understand something??
thank you
0
 
LVL 75
ID: 36546759
Sure ...

Private Sub btnViewPdf()

    Shell "C:\SomeFolder\YourPdfName.PDF", vbNormalFocus

End Sub
0
 

Author Comment

by:davetough
ID: 36546763
thanks - for help and explanation
0
 
LVL 75
ID: 36546771
You are welcome ...

mx
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

In the previous article, Using a Critera Form to Filter Records (http://www.experts-exchange.com/A_6069.html), the form was basically a data container storing user input, which queries and other database objects could read. The form had to remain op…
The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

758 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now