Results 1 to 11 of 11

Thread: [RESOLVED] adding a text box to a powerpoint slide

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Sep 2005
    Posts
    586

    Resolved [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?

  2. #2
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    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.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Sep 2005
    Posts
    586

    Re: adding a text box to a powerpoint slide

    this is the code I got:


    -------------------------

    VB Code:
    1. Const msotrue = True
    2. Const msofalse = False
    3. Const msoTextOrientationHorizontal = True
    4.  
    5.     ActiveWindow.Selection.SlideRange.Shapes.AddTextbox(msoTextOrientationHorizontal, 53.875, 389.125, 119#, 28.875).Select
    6.     ActiveWindow.Selection.ShapeRange.TextFrame.WordWrap = msotrue
    7.     With ActiveWindow.Selection.TextRange.ParagraphFormat
    8.         .LineRuleWithin = msotrue
    9.         .SpaceWithin = 1
    10.         .LineRuleBefore = msotrue
    11.         .SpaceBefore = 0.5
    12.         .LineRuleAfter = msotrue
    13.         .SpaceAfter = 0
    14.     End With
    15.     ActiveWindow.Selection.ShapeRange.TextFrame.TextRange.Characters(Start:=1, Length:=0).Select
    16.     With ActiveWindow.Selection.TextRange
    17.         .Text = "rwerwerwr"
    18.         With .Font
    19.             .Name = "Arial"
    20.             .NameComplexScript = "Arial"
    21.             .NameOther = "Arial"
    22.             .Size = 18
    23.             .Bold = msofalse
    24.             .Italic = msofalse
    25.             .Underline = msofalse
    26.             .Shadow = msofalse
    27.             .Emboss = msofalse
    28.             .BaselineOffset = 0
    29.             .AutoRotateNumbers = msofalse
    30.         '    .Color.SchemeColor = ppForeground
    31.         End With
    32.     End With
    33.     ActiveWindow.Selection.SlideRange.Shapes("Object 9").Select

    ------------------


    ( I added the first 3 lines)

    I get error 91 object variable or with block not set
    Last edited by RobDog888; May 14th, 2006 at 02:06 AM. Reason: Added [vbcode] tags

  4. #4
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    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?
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    Sep 2005
    Posts
    586

    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?

  6. #6
    Frenzied Member cssriraman's Avatar
    Join Date
    Jun 2005
    Posts
    1,465

    Re: adding a text box to a powerpoint slide

    have you set reference to Powerpoint object library?
    CS

  7. #7

    Thread Starter
    Fanatic Member
    Join Date
    Sep 2005
    Posts
    586

    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.

  8. #8

    Thread Starter
    Fanatic Member
    Join Date
    Sep 2005
    Posts
    586

    Re: adding a text box to a powerpoint slide

    anyone? I know this must be simple...

  9. #9

    Thread Starter
    Fanatic Member
    Join Date
    Sep 2005
    Posts
    586

    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"

  10. #10
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    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.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  11. #11

    Thread Starter
    Fanatic Member
    Join Date
    Sep 2005
    Posts
    586

    Re: adding a text box to a powerpoint slide

    Ok, I think I got It. thanks a lot !

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width