Solved

view a pdf file from access form

Posted on 2011-09-15
9
461 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 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
Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

 
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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

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

Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
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…

733 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