A
Alon
Hi,
I've been working on developing solutions to automate some of my
presentations so that macros that I usually run in applications other
than PowerPoint (such as Excel for instance) can be run directly from
PowerPoint by embedding Excel object into my presentations.
I recently ran into an error in one of my VBA scripts that I just
can't figure out how to fix. The code is the following (title and rule
are passed in string variables), it is designed to add a slide to the
end of the presentation and then add an excel sheet onto it:
ActivePresentation.Slides.Add(Index:=(ActivePresentation.Slides.Count
+ 1), Layout:=ppLayoutBlank).Select
ActiveWindow.Selection.SlideRange.Shapes.AddOLEObject(Left:=120,
Top:=110, Width:=480, Height:=320, ClassName:="Excel.Sheet",
Link:=msoFalse).Select
With ActiveWindow.Selection.ShapeRange
.Name = title
With .OLEFormat.Object
.Sheets.Add.Name = "Data"
.Sheets("Sheet1").Name = "Config"
.Sheets("Config").Visible = False
.Sheets("Config").Range("A1").Value = title 'The name in
A1
.Sheets("Config").Range("A2").Value = rule 'Rules in A2
End With
End With
Even though everything runs and each step is executed, I get the
following error:
Runtime error(91): Object variable or with block variable not set
Any help would be greatly appreciated. I have tried to keep out any
code that isn't needed, but can provide more info if needed to give a
better understanding. Again, everything runs fine, but I still get
that annoying runtime error 'almost' each time, but I can't find a
pattern as to when it comes up and when it doesn't.
Thanks,
Alon
I've been working on developing solutions to automate some of my
presentations so that macros that I usually run in applications other
than PowerPoint (such as Excel for instance) can be run directly from
PowerPoint by embedding Excel object into my presentations.
I recently ran into an error in one of my VBA scripts that I just
can't figure out how to fix. The code is the following (title and rule
are passed in string variables), it is designed to add a slide to the
end of the presentation and then add an excel sheet onto it:
ActivePresentation.Slides.Add(Index:=(ActivePresentation.Slides.Count
+ 1), Layout:=ppLayoutBlank).Select
ActiveWindow.Selection.SlideRange.Shapes.AddOLEObject(Left:=120,
Top:=110, Width:=480, Height:=320, ClassName:="Excel.Sheet",
Link:=msoFalse).Select
With ActiveWindow.Selection.ShapeRange
.Name = title
With .OLEFormat.Object
.Sheets.Add.Name = "Data"
.Sheets("Sheet1").Name = "Config"
.Sheets("Config").Visible = False
.Sheets("Config").Range("A1").Value = title 'The name in
A1
.Sheets("Config").Range("A2").Value = rule 'Rules in A2
End With
End With
Even though everything runs and each step is executed, I get the
following error:
Runtime error(91): Object variable or with block variable not set
Any help would be greatly appreciated. I have tried to keep out any
code that isn't needed, but can provide more info if needed to give a
better understanding. Again, everything runs fine, but I still get
that annoying runtime error 'almost' each time, but I can't find a
pattern as to when it comes up and when it doesn't.
Thanks,
Alon