Solved

view a pdf file from access form

Posted on 2011-09-15
9
436 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
Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
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…

912 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

23 Experts available now in Live!

Get 1:1 Help Now