Click to See Complete Forum and Search --> : [RESOLVED] adding a text box to a powerpoint slide
bambo
May 13th, 2006, 03:25 PM
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?
RobDog888
May 13th, 2006, 03:34 PM
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.
bambo
May 14th, 2006, 12:38 AM
this is the code I got:
-------------------------
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
RobDog888
May 14th, 2006, 02:07 AM
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?
bambo
May 14th, 2006, 06:08 AM
I know I need :
Dim OPwrPnt As Object
Set OPwrPnt = CreateObject("Powerpoint.application")
but how to connect OPwrpnt to this code?
cssriraman
May 14th, 2006, 07:48 AM
have you set reference to Powerpoint object library?
bambo
May 14th, 2006, 08:25 AM
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.
bambo
May 14th, 2006, 09:49 AM
anyone? I know this must be simple...
bambo
May 14th, 2006, 10:51 AM
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"
RobDog888
May 14th, 2006, 02:52 PM
If you added a reference to PowerPoint then you shouldnt need to manuall define the consts.
bambo
May 15th, 2006, 01:31 AM
Ok, I think I got It. thanks a lot !
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.