Please help - PowerPoint error with VB 6.0 automation

G

Guest

I am getting a nasty error whenever I try to open a PowerPoint presentation through VB 6.0. Here is my code:

Set m_prPowerPoint = m_apPowerPoint.Presentations.Open(p_filename)

The error occurs at the end of the Presentation_PresentationOpen event.

The code works on my computer, but when I take the code to the network where it will be used, it does not work. The following is the error I am getting:

In the message title bar: -2147188160
Error: "AACG_ClearFavBar Err -2147188160 - Application(unknown member): Invalid request. There is no active presentation."

Note - I do NOT get this error when I create a new presentation:
Set m_prPowerPoint = m_apPowerPoint.Presentations.Add,
only when I open one.

Please help!! Thank you in advance!
 
S

Shyam Pillai

Marcy,
Without the relevant code bits it's hard to ascertain the exact cause.
Invalid request. There is no active presentation usually occurs when you
attempt to the ActivePresentation when no document window is open even it
the presentation might be open.
 
G

Guest

Nothing much in the PresentationOpen:

Private Sub m_apPowerPoint_PresentationOpen(ByVal Pres As PowerPoint.Presentation)
Dim prs As PowerPoint.Presentation

MsgBox "start pres open event"

'add all pres's to the menu bar in case pres's were brought in from the outside
'addtomenu takes care of presentations that are already listed in the menu
For Each prs In g_apPPT.Presentations
If Not g_WebPowerPointDict.Exists(prs.Path & "\" & prs.Name) Then AddToMenu prs.Name
Next

MsgBox "end pres open event"

End Sub

The error occurs after the second messagebox, code stops executing until you hit "Okay" on the error. After hitting okay, the WindowActivate event is invoked. Code for that is:

Private Sub m_apPowerPoint_WindowActivate(ByVal Pres As PowerPoint.Presentation, _
ByVal Wn As PowerPoint.DocumentWindow)
MsgBox "start window activate event"

'if ppt is activated after closing, it means the user hit cancel and some point and
'that the name must be added back to the menu
If m_blnClosing Then AddToMenu Pres.Name

'check the presentation name and save the name of the presentation to a variable
CheckOnActivate Pres.Name

m_OrigName = Wn.Caption

'this function brings the mdi form to the top if there was another form or
'window in front of the mdi form when this child form was activated
ShowWindow mdiMain.hwnd, SW_SHOWNA

MsgBox "end window activate event"
End Sub

However, this event is probably irrelevant since the error has already occured.

Also, after hitting okay on the powerpoint error, the powerpoint presentation continues to open but i no longer have control over it.
 
S

Shyam Pillai

Marcy,
Have you tried to set breakpoints and step thru the code to arrive at the
errant line?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top