Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

open a pdf after exporting idw to PDF

3 REPLIES 3
Reply
Message 1 of 4
ulf
Contributor
385 Views, 3 Replies

open a pdf after exporting idw to PDF

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
3 REPLIES 3
Message 2 of 4
pds
Participant
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
Message 3 of 4
ulf
Contributor
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
Message 4 of 4
pds
Participant
in reply to: ulf

1-0 to you, thanks for sharing.

/Patrick

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report