open a pdf after exporting idw to PDF

open a pdf after exporting idw to PDF

Anonymous
Not applicable
562 Views
3 Replies
Message 1 of 4

open a pdf after exporting idw to PDF

Anonymous
Not applicable
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
0 Likes
563 Views
3 Replies
Replies (3)
Message 2 of 4

Anonymous
Not applicable
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
0 Likes
Message 3 of 4

Anonymous
Not applicable
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

Anonymous
Not applicable
1-0 to you, thanks for sharing.

/Patrick
0 Likes