Solved

PowerPoint 2010 VBA AddTextBox Error

Posted on 2013-10-22
10
1,552 Views
Last Modified: 2013-12-23
Hi,

I developed an MS Excel script that automates the addition and placement of text boxes in PowerPoint slides, and populates those text boxes with Excel data.  The script works fine in Excel 2007.  But, when I try running it in Excel 2010, I get the following Error: “The remote server machine does not exist or is unavailable.”  The error occurs specifically on the line where a new text box is added to a slide:

 Set objPPTextBox = objPPSlide.Shapes.AddTextbox(Orientation:=msoTextOrientationHorizontal, _
                    Left:=intLeft, Top:=intTop, Width:=intWidth, Height:=intHeight)

It fails when I try both early binding and late binding techniques.  Any thoughts?

Thank You
0
Comment
Question by:crpcsol
  • 2
10 Comments
 
LVL 81

Accepted Solution

by:
byundt earned 500 total points
ID: 39604724
I'm sure that one of the PowerPoint Experts could produce much more elegant code, but the following macro launches PowerPoint, creates a new presentation, creates a new slide, and puts a textbox on that slide in a specified location and with a specified size. It uses late-binding, and runs in Excel 2010.
Sub PPTtester()
Dim objPP As Object
Dim objPPSlide As Object, objPPTextBox As Object, objPPpresentation As Object
Dim intLeft As Integer, intTop As Integer, intWidth As Integer, intHeight As Integer
intLeft = 10
intTop = 20
intWidth = 350
intHeight = 100
Set objPP = CreateObject("Powerpoint.Application")
objPP.Visible = True
objPP.Presentations.Add
Set objPPpresentation = objPP.Presentations(1)
objPPpresentation.Slides.Add 1, 2
Set objPPSlide = objPPpresentation.Slides(1)
objPPSlide.Shapes.AddTextbox(Orientation:=msoTextOrientationHorizontal, _
                    Left:=intLeft, Top:=intTop, Width:=intWidth, Height:=intHeight).TextFrame.TextRange.Text = "Test Box"


End Sub

Open in new window

0
 
LVL 46

Expert Comment

by:Martin Liss
ID: 39687744
I've requested that this question be deleted for the following reason:

Not enough information to confirm an answer.
0
 
LVL 81

Assisted Solution

by:byundt
byundt earned 500 total points
ID: 39687745
I think the question was answered, using a single statement to create the textbox, size and position it, and assign the text.

Should the Asker want to create a textbox object, then you could use two statements as shown below:
Sub PPTtester()
Dim objPP As Object
Dim objPPSlide As Object, objPPTextBox As Object, objPPpresentation As Object
Dim intLeft As Integer, intTop As Integer, intWidth As Integer, intHeight As Integer
intLeft = 10
intTop = 20
intWidth = 350
intHeight = 100
Set objPP = CreateObject("Powerpoint.Application")
objPP.Visible = True
objPP.Presentations.Add
Set objPPpresentation = objPP.Presentations(1)
objPPpresentation.Slides.Add 1, 2
Set objPPSlide = objPPpresentation.Slides(1)
Set objPPTextBox = objPPSlide.Shapes.AddTextbox(Orientation:=msoTextOrientationHorizontal, _
                    Left:=intLeft, Top:=intTop, Width:=intWidth, Height:=intHeight)
objPPTextBox.TextFrame.TextRange.Text = "Test Box"
End Sub

Open in new window


Although the suggested code works on my computer (and is easily tested), it may not fix the Asker's problem. If so, it is incumbent on the Asker to revert back with more information--such as the code he is trying to use.
0
 
LVL 23

Expert Comment

by:JSRWilson
ID: 39689352
Agree

The poster needs to get back or byundyt's answer should be accepted

The code from byundyt works fine for me (Top, Left,Width and Height should technically be Singles not Integers  but it works fine)
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Many programs have tried to outwit PowerPoint in terms of technology and skill. These programs, however, still lack several characteristics that PowerPoint has possessed from the start. Here's why PowerPoint replacements won't entirely work for desi…
Freeze panes is an option within all variants of Excel to enable parts of a sheet to remain stationary when the cursor is in another part of the sheet. This is a very useful feature which is overlooked or under used.
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question