Академический Документы
Профессиональный Документы
Культура Документы
1. Questions
2. Developer Jobs
3. DocumentationBETA
4. Tags
5. Users
1.
2.
Log In Sign Up
up I am attempting to take the value in Excel cells and populate PowerPoint text boxes. I
vote0do don't want to link a PowerPoint table to an Excel spreadsheet because the spreadsheet is
wn vote favorite
constantly changing and values are not always in the same rows or the same order.
So I am writing this VBA code to try and populate the text boxes. I've done a lot of
VBA, but never attempted this combination. Below is what I have thus far (more code
will be put in for additional text boxes, but need to get one working first). I realize the
issue has something to do with the object not being properly handled, but not sure how to
correct it.
I'm using Excel and PowerPoint 2007. The bold statement is where I receive the error -
438 object does not support this property or method.
Thanks!
Sub valppt()
PPT.Presentations.Open "C:\Documents\createqchart.pptx"
Range("F2").Activate
slideCtr = 1
slideCtr = slideCtr + 1
' Do Until ActiveCell.Value = ""
Do Until slideCtr > 2
If slideCtr = 2 Then
tb.TextFrame2.TextRange.Characters.Text = ActiveCell.Value
End If
ActiveCell.Offset(0, 1).Activate
slideCtr = slideCtr + 1
If slideCtr = 38 Then
Set newslide = PPT.ActivePresentation.Slides(slideCtr).Duplicate
ActiveCell.Offset(1, -25).Activate
End If
Loop
End Sub
UPDATE 5/17
While the replication of the slide works, I am still unable to value the textbox. I haven't
been able to come up with the right set statement prior to the statement to have the value
assigned to the textbox. Right now I don't even have a set statement in there right now,
because I haven't been able to get the proper one. Any assistance is appreciated. Below is
the latest code.
Sub shptppt()
'
' shptppt Macro
'
Range("F2").Activate
slideCtr = 1
pres.Slides(slideCtr).Copy
pres.Slides.Paste
Set newslide = pres.Slides(pres.Slides.Count)
newslide.MoveTo slideCtr + 1
slideCtr = slideCtr + 1
' Do Until ActiveCell.Value = ""
Do Until slideCtr > 2
If slideCtr = 2 Then
tb.Slides.TextFrame2.TextRange.Characters.Text = ActiveCell.Value
End If
ActiveCell.Offset(0, 1).Activate
slideCtr = slideCtr + 1
If slideCtr = 38 Then
Set newslide = PPT.ActivePresentation.Slides(slideCtr).Duplicate
ActiveCell.Offset(1, -25).Activate
End If
Loop
End Sub
excel vba excel-vba textbox powerpoint
shareimprove this question edited Jan 19 '16 at 7:38 asked May 16 '13 at 15:03
1 What is txtReqBase?? It is not declared anywhere in your code, and does not appear to be a valid
object/property/method in PPT. Same error will probably happen with txtReqCurr. David Zemens May 16 '13 at
15:11
add a comment
2 Answers
activeoldestvotes
up txtReqBase is not valid. it's not declared as a variable in your code, and it's certainly not a
vote1d supported property/method in Powerpoint, and that's why you're getting the 438 error.
own To insert text in a shape, you need to identify the shape and then manipulate its .Text. I
vote find it easiest to do this with a shape variable.
'## If you have enabled reference to Powerpoint, then:'
Dim tb As Powerpoint.Shape
'## If you do not enable Powerpoint reference, use this instead'
'Dim tb as Variant '
Set tb = newSlide.Shapes("TextBox1") '## Update this to use the correct name or index of the shapes
collection ##'
tb.TextFrame2.TextRange.Characters.Text = ActiveCell.Value
UPDATE For Mismatch error setting tb.
I'm thinking you're getting the mismatch error because you have PPT As Object rather
than enabling a reference to the Powerpoint Object Library which would allow you to fully
dimension it as a PowerPoint.Application.
Your current code interprets Dim tb as Shape refers to an Excel.Shape, not a
Powerpoint.Shape.
If you enable reference to the Powerpoint Object Library, then you can do
Sub PPTTest()
Range("F2").Activate
slideCtr = 1
David Zemens
38.8k83773
Thanks David. I had actaully changed txtReqBase back to TexBox1 after I posted this. I was originally trying to give it
a unique identifier. I tried your code, but the set statement actually produces a type mismatch. Spiderman May 16 '13
at 17:01
Also why do you Dim tb as a Shape rather than an object? Spiderman May 16 '13 at 17:27
A TextBox is a member of the slide's Shapes collection. Dimensioning it specifically as a Shape, rather than a generic
Object/Variant enables the script-assist feature in the VBE. David Zemens May 16 '13 at 17:35
See revision above, re the mismatch error. David Zemens May 16 '13 at 17:41
I had tried to define references earlier as PowerPoint....., but this version of Excel (2007) does not recognize it as a
valid type. Spiderman May 16 '13 at 17:53
show 11 more comments
up I had forgotten that I had switched from a textbox to an activex control textbox. here's
vote0do the correct code now.
wn vote valppt()
Dim PPT As PowerPoint.Application
Dim newslide As PowerPoint.SlideRange
Dim slideCtr As Integer
Dim tb As PowerPoint.Shape
Set PPT = CreateObject("PowerPoint.Application")
PPT.Visible = True
PPT.Presentations.Open ("C:\Documents\createqchart.pptx")
Range("F2").Activate
slideCtr = 1
Set newslide = PPT.ActivePresentation.Slides(slideCtr).Duplicate
Set tb = newslide.Shapes("TextBox" & slideCtr)
slideCtr = slideCtr + 1
Do Until ActiveCell.Value = ""
'Do Until slideCtr > 2
If slideCtr = 2 Then
tb.OLEFormat.Object.Value = Format(ActiveCell.Value, "m/d/yyyy")
End If
ActiveCell.Offset(0, 1).Activate
slideCtr = slideCtr + 1
If slideCtr = 38 Then
Set newslide = PPT.ActivePresentation.Slides(slideCtr).Duplicate
ActiveCell.Offset(1, -25).Activate
End If
Loop
End Sub
shareimprove this answer answered May 17 '13 at 20:14
Spiderman
26228
add a comment
Your Answer
Sign up or log in
Sign up using Google
Post as a guest
Name
Email
Post Your Answer
By posting your answer, you agree to the privacy policy and terms of service.
Not the answer you're looking for? Browse other questions tagged excel vba excel-
vba textbox powerpoint or ask your own question.
asked
4 years, 3 months ago
viewed
27,806 times
active
1 year, 7 months ago
BLOG
Software Engineer
DatadogNew York, NY
REMOTE
gopython
Linked
0
Real Time Excel Calculation in powerpoint
0
Applying loop to copy-paste range of cells from excel to PowerPoint 2013
Related
5
EXcel VBA : Excel Macro to create table in a PowerPoint
1
Excel / PowerPoint text size after shrink to fit
5
Close Powerpoint Object with Excel VBA (NOT using Powerpoint.Application)
0
Unable to populate PowerPoint TextBox with value in Excel cell using VBA
0
Populate A Table in a Powerpoint Template Using Cells in Excel - VBA
1
Unable to extract Powerpoint textbox contents into Excel using Excel VBA
1
Loop through excel-spreadsheet-rows until empty using VBA-macro in powerpoint. For each row read values and
write to 2-dim-array. No .select
1
using VBA in Excel to paste into Powerpoint
1
Error in Code to Paste / Copy Shapes from Excel to PowerPoint VBA
1
Powerpoint VBA dont close Excel
question feed
STACK OVERFLOW
Questions
Jobs
Developer Jobs Directory
Documentation
Help
Mobile
STACK OVERFLOW
BUSINESS
Talent
Ads
Enterprise
Insights
COMPANY
About
Press
Work Here
Legal
Privacy Policy
Contact Us
STACK EXCHANGE
NETWORK
Technology
Life / Arts
Culture / Recreation
Science
Other
Blog
LinkedIn
site design / logo 2017 Stack Exchange Inc; user contributions licensed under cc by-sa
3.0with attribution required. rev 2017.8.22.26825