[RESOLVED] adding a text box to a powerpoint slide
Hey,
using MS Access, I've created a powerpoint slide with a pie chart based on a query. what I'd like to do now is add a text box with a title to this slide.
for adding the chart I've used an MS article that uses this line:
Set shpGraph = OpwrPresent.Shapes.AddOLEObject(left:=LLeft, _
top:=lTop, Width:=lwidth, Height:=lheight, _
ClassName:="MSGraph.Chart", Link:=0).OLEFormat.Object
any idea what classname is used for text box? or if I should do this in another way?
Re: adding a text box to a powerpoint slide
Record a macro in powerpoint adding the textbox. Then check out the generated module code to see how its done. Then move/modify it to Access.
Re: adding a text box to a powerpoint slide
this is the code I got:
-------------------------
VB Code:
Const msotrue = True
Const msofalse = False
Const msoTextOrientationHorizontal = True
ActiveWindow.Selection.SlideRange.Shapes.AddTextbox(msoTextOrientationHorizontal, 53.875, 389.125, 119#, 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 = "rwerwerwr"
With .Font
.Name = "Arial"
.NameComplexScript = "Arial"
.NameOther = "Arial"
.Size = 18
.Bold = msofalse
.Italic = msofalse
.Underline = msofalse
.Shadow = msofalse
.Emboss = msofalse
.BaselineOffset = 0
.AutoRotateNumbers = msofalse
' .Color.SchemeColor = ppForeground
End With
End With
ActiveWindow.Selection.SlideRange.Shapes("Object 9").Select
------------------
( I added the first 3 lines)
I get error 91 object variable or with block not set
Re: adding a text box to a powerpoint slide
What line is giving you the error? Did you create a object variable for the application object of powerpoint so Access doesnt get confused with its application object?
Re: adding a text box to a powerpoint slide
I know I need :
Dim OPwrPnt As Object
Set OPwrPnt = CreateObject("Powerpoint.application")
but how to connect OPwrpnt to this code?
Re: adding a text box to a powerpoint slide
have you set reference to Powerpoint object library?
Re: adding a text box to a powerpoint slide
It will be easier for me if you could please relate to the above code as the only code, and if anything is missing (and it is only few lines) sugget it as something to solve my problem.
Re: adding a text box to a powerpoint slide
anyone? I know this must be simple...
Re: adding a text box to a powerpoint slide
Ok I added "OPwrPnt." before every "activewindow..."
It still doesn't run saying msoTextOrientationHorizontal, msoFalse, and msoTrue are not defined in MS Acesss (but are defined in Powerpoint)
I tried to defined them as const text string, but it I get type mismatch error:
Const msoTextOrientationHorizontal = "msoTextOrientationHorizontal"
Re: adding a text box to a powerpoint slide
If you added a reference to PowerPoint then you shouldnt need to manuall define the consts.
Re: adding a text box to a powerpoint slide
Ok, I think I got It. thanks a lot !