Solved

PowerPoint 2010 VBA AddTextBox Error

Posted on 2013-10-22
10
1,591 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 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 48

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

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
How to get Spreadsheet Compare 2016 working with the 64 bit version of Office 2016
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

696 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