Opening and terminating outside application

Chuck6475

Board Regular
Joined
Sep 30, 2012
Messages
126
2003 w/7

I'm producing PDF for a slide show and using Reader in Full Page mode to display them.

The issue was to give interim results and therefore I'd need to either Close the old file prior to generating a new (PDF) file for Reader OR I'd have to Quit Reader and make a new PDF file and open Reader again.

I decided to do the later. I tested the sub parts of this routine and they worked fine (don't like SendKeys but...)

Now that I have combined the Kill with the Open, it seems I don't get the Kill. I end up with multiple version of Reader open with different files. (iPDF is a Public variable set to 1 in the initialization routine.)

Code:
Sub OpenPDFdoc()
Dim j As Integer
Dim TaskID As Variant

'  http://www.tek-tips.com/viewthread.cfm?qid=416162
'   pieces of Code  from above site
'    MsgBox "This will fail if you don't have Adobe Acrobat installed :o)"
    On Error GoTo 1
    
 ' Kill prior version of slide show before generating a new one.
 
If iPDF <> 1 And TaskID > 0 Then
            AppActivate TaskID
            Application.SendKeys "%{F4}", True
    End If
    
  'Launch a new slide show

   TaskID = Shell("C:\Program Files (x86)\Adobe\Reader 9.0\Reader\AcroRd32.exe", vbNormalFocus)
    
    ActiveWorkbook.FollowHyperlink ActiveWorkbook.Path & "\lmgc test files\" & "full Results" & iPDF & ".pdf", NewWindow:=True
     Application.SendKeys ("^l")
 iPDF = iPDF + 1
    Exit Sub
1:
End Sub
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.

Forum statistics

Threads
1,215,507
Messages
6,125,212
Members
449,214
Latest member
mr_ordinaryboy

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top