XP upgrade- VBA code no longer working (exporting from XL to PP)

K

Keith R

My company just upgraded me from Win95/O97 to WinXP/OXP.

I have an excel workbook that exports sections of data and graphs to PP, and
now it isn't working. For me or the other two users- we all got upgraded at
the same time.

I get a VB error msgbox with runtime error '-2147188160 (80048240)'
Application (unknown member) invalid request. There is no currently active
document window. When I hit debug it highlights the line of code marked
below. PP opened, but opens without a blank document.Apparently the syntax
for adding a new (blank) slide has changed? Any help appreciated... I don't
do much in PP so I'm not familiar enough with the syntax to effectively
troubleshoot...
Many thanks,
Keith


Sub CreatePresentation(PP1 As Boolean, PP2 As Boolean, PP3 As Boolean, PP4
As Boolean, PP5 As Boolean, PP6 As Boolean, PP7 As Boolean, PPName As
String)
Dim ppt As PowerPoint.Application
Dim lngHeight As Long
Dim lngWidth As Long
Dim pres As PowerPoint.Presentation
Dim pptShape As PowerPoint.Shape
Dim txtFrame As PowerPoint.TextFrame
Dim i As Integer
Dim SlideCount As Integer

'Determine how many slides to create
SlideCount = 0
If PP1 = True Then SlideCount = SlideCount + 3
If PP2 = True Then SlideCount = SlideCount + 1
If PP3 = True Then SlideCount = SlideCount + 1
If PP4 = True Then SlideCount = SlideCount + 1
If PP5 = True Then SlideCount = SlideCount + 1
If PP6 = True Then SlideCount = SlideCount + 1
If PP7 = True Then SlideCount = SlideCount + 1

If SlideCount > 0 Then
ReDim newSlide(1 To SlideCount) As PowerPoint.Slide
End If

'Create the PowerPoint Object
Set ppt = CreateObject("PowerPoint.Application")
Set pres = ppt.Presentations.Add 'Adds a blank presentation?
lngHeight = pres.PageSetup.SlideHeight
lngWidth = pres.PageSetup.SlideWidth

'For i = 1 To SlideCount
i = 1
If PP1 = True Then
Set newSlide(i) = pres.Slides.Add(i, ppLayoutBlank) 'add slide?
Sheet13.Activate
ActiveWindow.DisplayGridlines = False
Sheet13.Range("A1:AU46").Select
Excel.ActiveWorkbook.Sheets("V1").Range("AU46").Activate
Selection.CopyPicture
ActiveWindow.DisplayGridlines = True
ppt.Activate
With ppt
.ActiveWindow.View.GotoSlide Index:=i '<--CRASH
.ActivePresentation.Slides(i).Shapes.Paste
.ActiveWindow.Selection.SlideRange.Shapes(1).Select
With .ActiveWindow.Selection.ShapeRange
.IncrementLeft 325.25
.IncrementTop 233.75
.ScaleWidth 0.9, msoFalse, msoScaleFromTopLeft
.ScaleHeight 0.9, msoFalse, msoScaleFromTopLeft
End With
.ActiveWindow.Selection.Unselect
End With
i = i + 1

<snip>
 
S

Shyam Pillai

Keith,
Move the following line ppt.Activate and place it immediately after Set ppt
= CreateObject("PowerPoint.Application")

So the code should now look like this:

' ------------- snipped lines of code ------------
Set ppt = CreateObject("PowerPoint.Application")
ppt.Activate
Set pres = ppt.Presentations.Add 'Adds a blank presentation?
' ------------- snipped lines of code ------------

A presentation created/opened when the PowerPoint window is hidden will have
no associated document window.
 

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