Solved

PowerPoint 2010 VBA AddTextBox Error

Posted on 2013-10-22
10
1,494 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 80

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 45

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 80

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
Outlook Free & Paid Tools
Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.

743 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now