• Industries
  • Products
  • Buy
  • Services & Support
  • Communities
  • Discussion Groups

    Autodesk Inventor Customization

    Reply
    Valued Contributor ulf
    Valued Contributor
    Posts: 62
    Registered: ‎10-21-2003

    open a pdf after exporting idw to PDF

    144 Views, 3 Replies
    10-26-2009 03:05 AM
    Hi!
    I'm using the PublishPDf sample code to export IDW's when we do a reivsion of a drawing, and it works fine, but I would like the PDF to "pop up" after I have made it (as it is doing if I print it to PDF995 as is our currentmethod). I wonder if theres an easy method to do this. My best try so far is to add the following code at the end:

    Dim oWord As Word.Document '.Application
    'On Error Resume Next
    Set oWord = CreateObject("Word.Document")
    oWord.FollowHyperlink Address:=oDataMedium.filename, NewWindow:=True
    oWord.Close (wdDoNotSaveChanges)
    Set oWord = Nothing

    ,but tI wondered if there was a more straightforward method

    Thanx

    Ulf
    Please use plain text.
    pds
    Member
    Posts: 5
    Registered: ‎10-22-2008

    Re: open a pdf after exporting idw to PDF

    10-26-2009 06:08 AM in reply to: ulf
    Hi Ulf

    Add the lines at the end of your code.

    The varialble ProgramPath is added to ensure language differens in the name of this folder in Windows, if you use Adobe Reader 10 just change the value from 9.0 to 10.0 to get the correct path of the Adobe Reader

    /Patrick


    Dim shellResult As Double
    Dim ProgramFilesPath As String
    ProgramFilesPath = Environ("PROGRAMFILES")
    On Error Resume Next
    shellResult = Shell(ProgramFilesPath & "\Adobe\Reader 9.0\Reader\AcroRd32.exe" & " " & oDataMedium.FileName, vbNormalFocus)
    If shellResult = 0 Then MsgBox "Launche of Adobe Reader failed.", vbCritical + vbOKOnly
    Please use plain text.
    Valued Contributor ulf
    Valued Contributor
    Posts: 62
    Registered: ‎10-21-2003

    Re: open a pdf after exporting idw to PDF

    10-26-2009 10:40 AM in reply to: ulf
    Thanks a lot Patrick!
    That worked great.

    ... but while I waited for an answer I found another solution which I tried out as well, and it might sometimes be more convenient, since I'm not sure which version of Acrobat Reader our designers use, or if they use an entire different program. If you or anyone else is interested, heres the code:
    In the declarations part of the module (the beginning)
    Public 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

    and in the code:
    Dim r As Long
    r = ShellExecute(0, "open", oDataMedium.filename, 0, 0, 1)
    If r < 32 Then MsgBox ("Couldn't start your PDF-reader")

    the code was found at:
    http://support.microsoft.com/kb/224816
    Please use plain text.
    pds
    Member
    Posts: 5
    Registered: ‎10-22-2008

    Re: open a pdf after exporting idw to PDF

    10-29-2009 07:37 AM in reply to: ulf
    1-0 to you, thanks for sharing.

    /Patrick
    Please use plain text.