Page 1 of 3 123 LastLast
Results 1 to 15 of 32
  1. #1
    2 Star Lounger
    Join Date
    Apr 2004
    Posts
    129
    Thanks
    0
    Thanked 0 Times in 0 Posts

    opening adobe PDF files (Made2Manage w/VBA)

    Here's an example of what I'm doing:
    Public Function cmdMaster_CLICK() As Boolean
    Dim appadob As Adobe.Application
    Set appadob = New Adobe.Application
    Set wrkFile = appadob.Workbooks
    wrkFile.Open "SERVER01EIMG"
    appadob.Visible = True
    Set wrkFile = Nothing
    Set appadob = Nothing
    End Function

    Basically I'm trying to open an Adobe PDF file on a diferrent server. I'm doing this with a Button but am unsure of how to code the click event. Any Suggestions?

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: opening adobe PDF files (Made2Manage w/VBA)

    What is the default action for .pdf files on your system? In other words, what happens if you double click a .pdf file in Windows Explorer?

  3. #3
    2 Star Lounger
    Join Date
    Apr 2004
    Posts
    129
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: opening adobe PDF files (Made2Manage w/VBA)

    it opens up adobe reader 6.0

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: opening adobe PDF files (Made2Manage w/VBA)

    Would it be OK if your code opened the PDF files in Adobe Reader, or do you need them to open in the full app?

  5. #5
    2 Star Lounger
    Join Date
    Apr 2004
    Posts
    129
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: opening adobe PDF files (Made2Manage w/VBA)

    adobe reader is fine. all it is are schematics. I want the user to click the button to open up the schematic in adobe.

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: opening adobe PDF files (Made2Manage w/VBA)

    Put the following declarations at the beginning of a module:

    Private Declare Function ShellExecute Lib "shell32.dll" 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

    Public Const SW_SHOWNORMAL = 1
    Public Const SW_SHOWMINIMIZED = 2
    Private Const SW_SHOWMAXIMIZED As Long = 3

    Then, adapt the following macro to your needs:

    Sub ShowPDF()
    Dim lngResult As Long

    lngResult = ShellExecute(0&, "Open", _
    "serversharefolderSomeFile.pdf", 0&, 0&, SW_SHOWMAXIMIZED)
    If lngResult <= 32 Then
    MsgBox "Something went wrong.", vbExclamation
    End If
    End Sub

  7. #7
    2 Star Lounger
    Join Date
    Apr 2004
    Posts
    129
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: opening adobe PDF files (Made2Manage w/VBA)

    not sure what this means, could you please elaborate:

    lngResult = ShellExecute(0&, "Open", _"serversharefolderSomeFile.pdf", 0&, 0&, SW_SHOWMAXIMIZED)
    If lngResult <= 32 Then
    MsgBox "Something went wrong.", vbExclamation
    End If

  8. #8
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: opening adobe PDF files (Made2Manage w/VBA)

    lngResult = ShellExecute(0&, "Open", _"serversharefolderSomeFile.pdf", 0&, 0&, SW_SHOWMAXIMIZED)

    must either be on two lines, as in my reply:

    lngResult = ShellExecute(0&, "Open", _
    "serversharefolderSomeFile.pdf", 0&, 0&, SW_SHOWMAXIMIZED)

    or on one line, but in that case without the underscore:

    lngResult = ShellExecute(0&, "Open", "serversharefolderSomeFile.pdf", 0&, 0&, SW_SHOWMAXIMIZED)

    And you should replace serversharefolderSomeFile.pdf with the name of the pdf file you want to open.

    ShellExecute is a Windows API function that performs one of the standard actions (open, print) on a file. It looks in the Windows registry to see which application should be started for the specified action. The result of ShellExecute is a number; if this is 32 or less, it is an error number indicating that the action didn't succeed, but if it is larger than 32, the action was successful.

  9. #9
    2 Star Lounger
    Join Date
    Apr 2004
    Posts
    129
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: opening adobe PDF files (Made2Manage w/VBA)

    But how do I get that within my click event for my button? and what does the "0&, 0&, SW_SHOWMAXIMIZED" Mean.

  10. #10
    2 Star Lounger
    Join Date
    Apr 2004
    Posts
    129
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: opening adobe PDF files (Made2Manage w/VBA)

    Hans:

    Here's what I have so far:

    Public Function INIT() As Boolean
    ThisForm.m2mpageframe1.page1.addobject "cmdMaster", "m2mbutton"
    With ThisForm.m2mpageframe1.page1.cmdMaster
    .Width = 50
    .Top = 285
    .Left = 16
    .Height = 35
    .caption = "Master"
    .Tooltiptext = "Click to View / Edit the Master EIMG files"
    .wordwrap = True
    .Visible = True
    .enabled = True
    .TabIndex = 13
    End With
    INIT = True

    Which Creates my Button as you very well know.

    But I'm not understanding how to link up what you wrote with what I have already.

  11. #11
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: opening adobe PDF files (Made2Manage w/VBA)

    Call ShowPDF from the On Click code of your command button.

    The arguments of Windows API functions are rather technical, and it's not really necessary to know what they mean, except for the last one. SW_SHOWMAXIMIZED specifies that Adobe Reader will be maximized. If you use SW_SHOWNORMAL instead, it will open in a non-maximized window.

    If you're interested in the details, see for example ShellExecute Function (Windows Explorer and Controls).

  12. #12
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: opening adobe PDF files (Made2Manage w/VBA)

    I don't even know what Made2Manage is.

    Does a command button have an OnAction property? If so, add a line

    .OnAction = "ShowPDF"

    between With... and End With.

  13. #13
    2 Star Lounger
    Join Date
    Apr 2004
    Posts
    129
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: opening adobe PDF files (Made2Manage w/VBA)

    Hans:

    Ok, I got that part.... please review.

    Private Declare Function ShellExecute Lib "shell32.dll" 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

    Public Const SW_SHOWNORMAL = 1
    Public Const SW_SHOWMINIMIZED = 2
    Private Const SW_SHOWMAXIMIZED As Long = 3

    Public Function m2mpageframe1_page1_cmdMaster_CLICK() As Boolean
    OnAction = "ShowPDF"
    Dim lngResult As Long
    lngResult = ShellExecute(0&, "Open", _
    "server01EIMG", 0&, 0&, SW_SHOWMAXIMIZED)
    If lngResult <= 32 Then
    MsgBox "Something went wrong.", vbExclamation
    End If
    End Function

    Whats happening now is that the message box ":something is wrong" keeps poppin up.

    the location for the files are on a different drive J:Server01EIMG*.PDF thats where all my pdf files are located. this program runs on the C: drive. do I need to point it to that drive as well?

  14. #14
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: opening adobe PDF files (Made2Manage w/VBA)

    The line

    OnAction = "ShowPDF"

    makes no sense, you should remove it. Since you have given your function the succinct name m2mpageframe1_page1_cmdMaster_CLICK, you should include a line
    <code>
    .OnAction = "m2mpageframe1_page1_cmdMaster_CLICK"
    </code>
    in the code that creates the command button, somewhere between With ... and End With.

    You must provide the path and name of a specific .pdf file, not just a path. And the path must be either of the form "J:FolderFolder..." or of the form "ServerShareFolder...", not a mixture of both.

    If you want the user to be able to select the pdf file, you must add more code. Since I don't know what Made2Manage is, I don't know whether that provides a way to select a file, such as FileDialog in recent Office applications and GetOpenFilename in Excel. If it does, you should use that, otherwise, more Windows API code will be needed.

  15. #15
    Super Moderator
    Join Date
    Jan 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    3,852
    Thanks
    4
    Thanked 259 Times in 239 Posts

    Re: opening adobe PDF files (Made2Manage w/VBA)

    Is there a reason you can't use a hyperlink type command such as
    ActiveDocument.FollowHyperlink Address:="file:SERVER01EIMGDefault.pdf"

    The above example is from Word so ActiveDocument is not going to work for you (I also don't know anything about Made2Manage) but if your application supports VBA then I would be surprised if it didn't have a method that opened a hyperlink.

    Looking at the file you are trying to open it looks suspiciously like a folder path not a file - I would expect to see a .PDF on the end of the path you are trying to open.
    Andrew Lockton, Chrysalis Design, Melbourne Australia

Page 1 of 3 123 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •