?
Solved

PowerPoint 2010 VBA AddTextBox Error

Posted on 2013-10-22
10
Medium Priority
?
1,632 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
10 Comments
 
LVL 81

Accepted Solution

by:
byundt earned 2000 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 49

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 2000 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

This article describes how to import an Outlook PST file to Office 365 using a third party product to avoid Microsoft's Azure command line tool, saving you time.
I was prompted to write this article after the recent World-Wide Ransomware outbreak. For years now, System Administrators around the world have used the excuse of "Waiting a Bit" before applying Security Patch Updates. This type of reasoning to me …
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

801 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