L
leef_me
I am not well versed in automation across applications. Can anyone help
me by testing, correcting my error, or confirming a PPT bug?
I have a working Excel macro that opens a Powerpoint file with song
lyrics, via automation. I have tried it under Win XP, PPT 2000 and
Execl 2000, without failure. In one set of conditions under Win XP, PPT
2002 and Execl 2002, I have an undesired condition: Powerpoint does not
move to the foreground.
Conditions to recreate the failure are as follows:
1) Under Win XP, PPT 2002 and Execl 2002
2) both application closed
3) open the Excel workbook with the macro, with macros enabled
4) use the macro to open the desired PPT file with lyrics
5) PPT comes to the foreground with the file visible
6) manually close the PPT file, leaving PPT application open
7) use the macro to open the desired PPT file with lyrics
8) the PPT file is opened, but PPT stays in the background, BAD
9) repeating steps 6 through 8 will give the same BAD result
10) closing PPT applicaton and repeating steps 4 & 5 is Good
Here is the code:
Sub open_song2()
' Row = ActiveCell.Row
' f1 = Cells(Row, 1).Value
f1 = "sample.ppt"
pptDir = "G:\"
pptpath = pptDir & f1
On Error Resume Next ' Defer error trapping.
Set PPApp = GetObject(, "Powerpoint.Application")
If Err.Number <> 0 Then
' MsgBox "Powerpoint was not open"
Set PPApp = CreateObject("Powerpoint.Application")
Err.Clear ' Clear Err object in case error occurred.
Else
' MsgBox "Powerpoint was already open"
End If
PPApp.Parent.Windows(1).Visible = True
PPApp.Activate
Set PPPres1 = PPApp.Presentations.Open(pptpath, , , True)
'AppActivate ("Powerpoint.Application")
' PPApp.Visible = True
PPPres1.Visible = True
PPPres1.Activate
End Sub
me by testing, correcting my error, or confirming a PPT bug?
I have a working Excel macro that opens a Powerpoint file with song
lyrics, via automation. I have tried it under Win XP, PPT 2000 and
Execl 2000, without failure. In one set of conditions under Win XP, PPT
2002 and Execl 2002, I have an undesired condition: Powerpoint does not
move to the foreground.
Conditions to recreate the failure are as follows:
1) Under Win XP, PPT 2002 and Execl 2002
2) both application closed
3) open the Excel workbook with the macro, with macros enabled
4) use the macro to open the desired PPT file with lyrics
5) PPT comes to the foreground with the file visible
6) manually close the PPT file, leaving PPT application open
7) use the macro to open the desired PPT file with lyrics
8) the PPT file is opened, but PPT stays in the background, BAD
9) repeating steps 6 through 8 will give the same BAD result
10) closing PPT applicaton and repeating steps 4 & 5 is Good
Here is the code:
Sub open_song2()
' Row = ActiveCell.Row
' f1 = Cells(Row, 1).Value
f1 = "sample.ppt"
pptDir = "G:\"
pptpath = pptDir & f1
On Error Resume Next ' Defer error trapping.
Set PPApp = GetObject(, "Powerpoint.Application")
If Err.Number <> 0 Then
' MsgBox "Powerpoint was not open"
Set PPApp = CreateObject("Powerpoint.Application")
Err.Clear ' Clear Err object in case error occurred.
Else
' MsgBox "Powerpoint was already open"
End If
PPApp.Parent.Windows(1).Visible = True
PPApp.Activate
Set PPPres1 = PPApp.Presentations.Open(pptpath, , , True)
'AppActivate ("Powerpoint.Application")
' PPApp.Visible = True
PPPres1.Visible = True
PPPres1.Activate
End Sub