Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

view a pdf file from access form

Posted on 2011-09-15
9
Medium Priority
?
486 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
[X]
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
  • 4
  • 2
  • 2
  • +1
9 Comments
 
LVL 75

Accepted Solution

by:
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform) earned 668 total points
ID: 36545890
How about this:

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

mx
0
 
LVL 85

Assisted Solution

by:Scott McDaniel (Microsoft Access MVP - EE MVE )
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 668 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
Fill in the form and get your FREE NFR key NOW!

Veeam® is happy to provide a FREE NFR server license to certified engineers, trainers, and bloggers.  It allows for the non‑production use of Veeam Agent for Microsoft Windows. This license is valid for five workstations and two servers.

 
LVL 85
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 664 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

Learn Veeam advantages over legacy backup

Every day, more and more legacy backup customers switch to Veeam. Technologies designed for the client-server era cannot restore any IT service running in the hybrid cloud within seconds. Learn top Veeam advantages over legacy backup and get Veeam for the price of your renewal

Question has a verified solution.

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

Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
We live in a world of interfaces like the one in the title picture. VBA also allows to use interfaces which offers a lot of possibilities. This article describes how to use interfaces in VBA and how to work around their bugs.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
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…

610 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