Solved

PowerPoint 2010 VBA AddTextBox Error

Posted on 2013-10-22
10
1,563 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 47

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Technology opened people to different means of presenting information, but PowerPoint remains to be above competition. Know why PPT still works today.
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.
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…

735 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