Important!! ActiveX component Can't create object Powerpoint in vb

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

from VB6, I open a PPT presentation. That's all fine. when I attempt to use
the addtextbox method I get this error. Other postings on this subject do not
solve my problem. I am using a licensed version Office 2003. I even
reinstalled it to repair files. This error usually happens if a dll is not
registered. However, since I've installed it twice...

Here's simple code. Note: error is on line with !!!! to the left.

Set AppPPT = CreateObject("PowerPoint.Application")
AppPPT.Visible = True

' If you want to hide the PowerPoint Window, set the visible property
' to FALSE and WithWindow argument of Open method to FALSE too.
AppPPT.Presentations.Open ("D:\Data\VBcode\VBPPT\sample.ppt")
With AppPPT.Presentations
' .Add WithWindow:=msoTrue
!!!!
ActiveWindow.Selection.SlideRange.Shapes.AddTextbox(msoTextOrientationHorizontal, 114, 102, 174, 28.875).Select
ActiveWindow.Selection.ShapeRange.TextFrame.WordWrap = msoTrue
With ActiveWindow.Selection.TextRange.ParagraphFormat
.LineRuleWithin = msoTrue
.SpaceWithin = 1
.LineRuleBefore = msoTrue
.SpaceBefore = 0.5
.LineRuleAfter = msoTrue
.SpaceAfter = 0
End With

ActiveWindow.Selection.ShapeRange.TextFrame.TextRange.Characters(Start:=1,
Length:=0).Select
With ActiveWindow.Selection.TextRange
.Text = "Red Hat"
With .Font
.Name = "Arial"
.Size = 18
.Bold = msoFalse
.Italic = msoFalse
.Underline = msoFalse
.Shadow = msoFalse
.Emboss = msoFalse
.BaselineOffset = 0
.AutoRotateNumbers = msoFalse
.Color.SchemeColor = ppForeground
End With




End With
End With
 
from VB6, I open a PPT presentation. That's all fine. when I attempt to use
the addtextbox method I get this error. Other postings on this subject do not
solve my problem. I am using a licensed version Office 2003. I even
reinstalled it to repair files. This error usually happens if a dll is not
registered. However, since I've installed it twice...

Let's make some changes and try it this way first:

' if you prefer, set a reference to PPT and dim
' these as Slide, Presentation and Shape respectively:
Dim oSlide as Object
Dim oPresentation as Object
Dim oSh as Object

Set AppPPT = CreateObject("PowerPoint.Application")
AppPPT.Visible = True

' If you want to hide the PowerPoint Window, set the visible property
' to FALSE and WithWindow argument of Open method to FALSE too.
Set oPresentation = AppPPT.Presentations.Open ("D:\Data\VBcode\VBPPT\sample.ppt")
Set oSlide = oPresentation.Slides(1)
' assuming you want to add the shape on slide one that is
Set oSh = oSlide.Shapes.AddTextbox(msoTextOrientationHorizontal, _
114, 102, 174, 28.875)
With oSh
.TextFrame.WordWrap = msoTrue
With .TextRange.ParagraphFormat
.LineRuleWithin = msoTrue
.SpaceWithin = 1
.LineRuleBefore = msoTrue
.SpaceBefore = 0.5
.LineRuleAfter = msoTrue
.SpaceAfter = 0
End With ' .ParagraphFormat

With .TextRange
.Text = "Red Hat"
With .Font
.Name = "Arial"
.Size = 18
.Bold = msoFalse
.Italic = msoFalse
.Underline = msoFalse
.Shadow = msoFalse
.Emboss = msoFalse
.BaselineOffset = 0
.AutoRotateNumbers = msoFalse
.Color.SchemeColor = ppForeground
End With ' font
End With ' text range
End With ' oSh

and so on.

Does that work?
 
Change the code to:

Set AppPPT = CreateObject("PowerPoint.Application")
AppPPT.Visible = True

' If you want to hide the PowerPoint Window, set the visible property
' to FALSE and WithWindow argument of Open method to FALSE too.
AppPPT.Presentations.Open ("D:\Data\VBcode\VBPPT\sample.ppt")
With APPPPT
'Note the use of the qualifying dot (.) before ActiveWindow
.ActiveWindow.Selection.SlideRange.Shapes.AddTextbox(msoTextOrientationHorizontal,
114, 102, 174, 28.875).Select
.ActiveWindow.Selection.ShapeRange.TextFrame.WordWrap = msoTrue
With ActiveWindow.Selection.TextRange.ParagraphFormat
.LineRuleWithin = msoTrue
.SpaceWithin = 1
.LineRuleBefore = msoTrue
.SpaceBefore = 0.5
.LineRuleAfter = msoTrue
.SpaceAfter = 0
End With

.ActiveWindow.Selection.ShapeRange.TextFrame.TextRange.Characters(Start:=1,
Length:=0).Select
With .ActiveWindow.Selection.TextRange
.Text = "Red Hat"
With .Font
.Name = "Arial"
.Size = 18
.Bold = msoFalse
.Italic = msoFalse
.Underline = msoFalse
.Shadow = msoFalse
.Emboss = msoFalse
.BaselineOffset = 0
.AutoRotateNumbers = msoFalse
.Color.SchemeColor = ppForeground
End With
End With


End With
 
Thanks and it still does not work. I get the same error. NOte: I am using the
following in my references:

Microsoft Powerpoint 11 Object library
Microsoft Office 11 object library
Visual Basic for Applications
Microsoft ActiveX Data Objects 2.7
 
Thanks and it still does not work. I get different error. 438 Object doesn't
support this property or method.

NOte: I am using the following in my references:

Microsoft Powerpoint 11 Object library
Microsoft Office 11 object library
Visual Basic for Applications
Microsoft ActiveX Data Objects 2.7
 
Thanks, It works.

However, I know I tried that but for some reason the intellisense isn't
working properly and .Active.... didn't show up as an option.

mm
 
Intellisense won't show up unless. You've declared the object correctly.
If you set a reference to the PowerPoint library and declare AppPPT as
PowerPoint.Application the intellisense will appear.
 
Back
Top