?
Solved

Command button to open PDF set size and return error if not there

Posted on 2011-03-18
3
Medium Priority
?
207 Views
Last Modified: 2012-06-22
Hi experts

I have the code below. It opens up a PDF in Acrobat.

I need to enhance this code by:
1) If the PDF doesn't exist it needs to return an error message to say "Can't find it". At the moment it just does nothing.
2) Is it possible to set the size of the PDF screen that appears? I'd like it to be half the screen size.

Option Explicit
Private Declare Function ShellExecute Lib "shell32" _
    Alias "ShellExecuteA" _
   (ByVal hwnd As Long, _
    ByVal lpOperation As String, _
    ByVal lpFile As String, _
    ByVal lpParameters As String, _
    ByVal lpDirectory As String, _
    ByVal nShowCmd As Long) As Long
    
Private Const SW_SHOWNORMAL As Long = 1
Private Const SW_SHOWMAXIMIZED As Long = 3
Private Const SW_SHOWDEFAULT As Long = 10
Private Const SE_ERR_NOASSOC As Long = 31

Private Sub CommandButton1_Click()
    Dim ThisDoc as Document
    Dim strOurRefGuide As String
    Set ThisDoc = ActiveDocument
    
    
    strOurRefGuide = ThisDoc.AttachedTemplate.Path & "\OurRefGuide.pdf"
    Call ShellExecute(0&, "open", strOurRefGuide, 0&, 0&, SW_SHOWNORMAL)



End Sub

Open in new window

0
Comment
Question by:Fi69
[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
  • 2
3 Comments
 
LVL 11

Accepted Solution

by:
Deepak Lakkad earned 2000 total points
ID: 35171134
Hi

make following change in your code to check whether file is exist or not?

IF Dir$(strOurRefGuide) <> "" THEN  'Search for file
   Call ShellExecute(0&, "open", strOurRefGuide, 0&, 0&, SW_SHOWNORMAL)
ELSE
    MsgBox "Your Error message"
END IF

Open in new window


- Deepak Lakkad
0
 

Author Comment

by:Fi69
ID: 35173875
Thank for that. The error code for if the file doesn't exist is now working.

Do you know how to change the code to resize the PDF that apepars?
0
 
LVL 11

Expert Comment

by:Deepak Lakkad
ID: 35174041
have no more idea about it but,  following links can help a little

http://support.microsoft.com/kb/170918
http://support.microsoft.com/kb/238245

- Deepak Lakkad
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

I would like to show you some basics you can do with Mailings in MS Word. It´s quite handy feature you can use for creating envelopes, labels, personalized letters etc. First question could be what is this feature good for? Mailing can really he…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
This video shows where to find templates, what they are used for, and how to create and save a custom template using Microsoft Word.
This Micro Tutorial well show you how to find and replace special characters in Microsoft Word. This is similar to carriage returns to convert columns of values from Microsoft Excel into comma separated lists.
Suggested Courses
Course of the Month13 days, 19 hours left to enroll

801 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