Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

view a pdf file from access form

Posted on 2011-09-15
9
456 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 - Microsoft MVP, Access and Data Platform) 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
The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

 
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
 
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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
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…

839 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