Inventor Customization

Reply
Valued Contributor ulf
Valued Contributor
Posts: 62
Registered: ‎10-21-2003
Message 1 of 4 (189 Views)

open a pdf after exporting idw to PDF

189 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
pds
Member
Posts: 5
Registered: ‎10-22-2008
Message 2 of 4 (189 Views)

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
Valued Contributor ulf
Valued Contributor
Posts: 62
Registered: ‎10-21-2003
Message 3 of 4 (189 Views)

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
pds
Member
Posts: 5
Registered: ‎10-22-2008
Message 4 of 4 (189 Views)

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

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Welcome to the new Autodesk Community!
If this is your first visit, click here to get started and make the most of the Community. Let us know what you think of the new experience in the Community Feedback Forum.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community


Inventor Exchange Apps

Created by the community for the community, Autodesk Exchange Apps for Autodesk Inventor helps you achieve greater speed, accuracy, and automation from concept to manufacturing.

Connect with Inventor

Twitter

Facebook

Blogs

Pinterest

Youtube