Solved

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

Posted on 2011-03-18
3
204 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
  • 2
3 Comments
 
LVL 11

Accepted Solution

by:
Deepak Lakkad earned 500 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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

Suggested Solutions

Title # Comments Views Activity
MS Word document > cursor placement 5 35
Regarding Notepad++ 4 47
Problem to line 23 55
Collapse and expand table in Word 2010 2 38
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…
Microsoft Word is a program we have all encountered at some point, but very few of us have dug deep into its full scope of features, let alone customized it to suit our needs. Luckily making the ribbon (aka toolbar, first introduced in Word 2007) wo…
Office 365 is currently available in five editions. Three of them are for business use: Office 365 Business Essentials, Office 365 Business, and Office 365 Business Premium. Two of them are for home/personal use: Office 365 Home and Office 365 Perso…
This Experts Exchange video Micro Tutorial shows how to tell Microsoft Office that a word is NOT spelled correctly. Microsoft Office has a built-in, main dictionary that is shared by Office apps, including Excel, Outlook, PowerPoint, and Word. When …

830 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