Copying text from an editable text box to a table cell

K

kimkom

Hi,

Hope you are all well.

I currently have some code in place to copy text from a table cell to
another table cell on another slide - something like this...

oTarget_table.Cell(1,2).Shape.TextFrame.TextRange.Text = _
oSource_table.Cell(1,2).Shape.TextFrame.TextRange.Text

Now...
I'm planning on using an editable text box as the text source which would
populate the destination table in the same way. Thus the user would be able
to enter their text while in the PPS and the text in the target table would
be updated.

How would my code change to make this happen?

Many thanks,
Michael
 
K

kimkom

Hi,

Thought it might be more useful if I posted the sub code. The chunk of the
code goes like this:

Sub DuplicateTable()

Dim oSource_table As Table
Set oSource_table = ActivePresentation.Slides(2).Shapes("SourceTable").Table

Dim oTarget_table As Table
Set oTarget_table = ActivePresentation.Slides(3).Shapes("TargetTable").Table

With oTarget_table

oTarget_table.Cell(1, 2).Shape.TextFrame.TextRange.Text = _
oSource_table.Cell(1, 2).Shape.TextFrame.TextRange.Text

End With

End Sub

So just to repeat my question, how would this alter to use text from an
editable text box instead of a table cell?

Thanks,
Michael
 
D

David Marcovitz

If the textbox is on Slide 1 and is named TextBox1, you can get the text
from it with:

Slide1.TextBox1.Text

If you have some other pointer (named myTextBox) to the text box, it
could be as simple as:

myTextBox.Text

This is for control (editable) text boxes. The syntax would be different
for regular autoshape text boxes.

--David
 
K

kimkom

Thanks for the reply David.

Unfortunately I'm still struggling to fing the correct syntax to get this to
work. I have tried what you suggested (which seems logical to me) but still
no joy. Also tried all variants of the syntax I could think of.

This is the working code i currently have in place which is doing the job
fine:

Sub DuplicateTable()

Dim oSource_table As Table
Set oSource_table = ActivePresentation.Slides(2).Shapes("SourceTable").Table

Dim oTarget_table As Table
Set oTarget_table = ActivePresentation.Slides(3).Shapes("PrintTable").Table

With oTarget_table

oTarget_table.Cell(1, 2).Shape.TextFrame.TextRange.Text = _
oSource_table.Cell(1, 2).Shape.TextFrame.TextRange.Text

End With

ActivePresentation.SlideShowWindow.View.GotoSlide 3

End Sub


This is applied to a button on slide 3 which when pressed, refreshes the
table on that slide with the information from a table on slide 2.

What I am trying to achieve now is to use editable text boxes in PPS mode to
populate the same table.

Any help would be gratefully received.

Many thanks,
Michael
 
D

David Marcovitz

You'll have to figure out some more information for us because we can
not look over your shoulder. The question is: exactly where is it that
you want to get the text from. You call it an editable textbox so I am
assuming it is a text box created with the control toolbox. However, I
could imagine it is a standard text box that you have gotten text into
in some other way. I could also imagine that you have used the InputBox
command to pop up a text box to input text. All of these things, and the
details accompanying them, will be needed to figure out the exact line
of code you need. The good news is that this sounds like something
really easy (i.e., getting text from an object) so once you identify the
object, we should be able to figure it out. I just don't know what the
object is without you telling me more details.
--David
 
K

kimkom

Hi David,

Apologies if the info provided was inadequate.

In answer to your question, I am trying to duplicate text from a Text Box
(ActiveX Control) inserted via the Developer tab in slide 2 of a
presentation.

The text will be inputted during runtime of the PPS and duplicated to three
separate tables on slide 3 of the same presentation.

I just can't figure out the correct syntax. Any help will be gratefully
appreciated.

Many thanks,
Michael
 
K

kimkom

Sorry Steve, what earlier reply? This seams to be your first post on this
thread, I can see no other. Do you mean you've already posted on this
subject? If so in what thread?

Thank you,
Michael
 
M

Michael Koerner

Steve's reply is the fourth from your original post with this one being the
11th. Can you not see all the messages in the thread?

--
Michael Koerner
MS MVP - PowerPoint


Sorry Steve, what earlier reply? This seams to be your first post on this
thread, I can see no other. Do you mean you've already posted on this
subject? If so in what thread?

Thank you,
Michael
 
K

kimkom

Hi Michael,

No I can't see Steve's first post. I am seeing 10 posts, 11 including this
one now. Something strange going on?

Michael
 
D

David Marcovitz

OK. Now that he has pasted his original response here, has his response
solved your problem?
--David
 
K

kimkom

Thanks Steve, I see that one now. Weird your earlier post doesn't show.

I'll have a go at your suggestion as soon as possible and post how it goes.

Thank you,
Michael
 
K

kimkom

Sorry guys, as you may have guessed I am a newbie to vba, and I'm really
struggling to get my head round what seems to be a really simple problem.
Thanks for all your input so far, I have tried numerous variations of the
suggested code syntax so far with no luck.

This is what I have working in place at the moment which drags text from a
table cell on one slide and duplicates it to another table on another slide:

Sub DuplicateTable()

Dim oSource_table As Table
Set oSource_table = ActivePresentation.Slides(2).Shapes("SourceTable").Table

Dim oTarget_table As Table
Set oTarget_table = ActivePresentation.Slides(3).Shapes("PrintTable").Table

With oTarget_table

oTarget_table.Cell(1, 2).Shape.TextFrame.TextRange.Text = _
oSource_table.Cell(1, 2).Shape.TextFrame.TextRange.Text

End With

ActivePresentation.SlideShowWindow.View.GotoSlide 3

End Sub


All I am trying to do now is change the source of the text to a
TextBox(ActiveX) inserted via the Developer tab, so it can be entered during
the PPS and duplicated to the destination table in the same way.

PLEASE HELP!

Thank you,
Michael
 
K

kimkom

Sorry guys, as you may have guessed I am a newbie to vba, and I'm really
struggling to get my head round what seems to be a really simple problem.
Thanks for all your input so far, I have tried numerous variations of the
suggested code syntax so far with no luck.

This is what I have working in place at the moment which drags text from a
table cell on one slide and duplicates it to another table on another slide:

Sub DuplicateTable()

Dim oSource_table As Table
Set oSource_table = ActivePresentation.Slides(2).Shapes("SourceTable").Table

Dim oTarget_table As Table
Set oTarget_table = ActivePresentation.Slides(3).Shapes("PrintTable").Table

With oTarget_table

oTarget_table.Cell(1, 2).Shape.TextFrame.TextRange.Text = _
oSource_table.Cell(1, 2).Shape.TextFrame.TextRange.Text

End With

ActivePresentation.SlideShowWindow.View.GotoSlide 3

End Sub


All I am trying to do now is change the source of the text to a
TextBox(ActiveX) inserted via the Developer tab, so it can be entered during
the PPS and duplicated to the destination table in the same way.

PLEASE HELP!

Thank you,
Michael
 
D

David Marcovitz

Please tell us:

(1) which slide the text box is on.
(2) what the name of the text box is (it defaults to something like
TextBox1 if you haven't changed it)

--David
 
K

kimkom

Okay guys, I've got this working now I think. Thanks for all your help. The
working code I have in place is more or less the same as Steve posted and
goes like this:


Function TheText(oSh As Shape)
If oSh.Type = msoOLEControlObject Then
TheText = oSh.OLEFormat.Object.Text
End If
End Function


Sub UpdatePrintTables()

Dim oSh As Shape
Dim oTarget_table As Table

Set oTarget_table =
ActivePresentation.Slides(3).Shapes("PrintTable1").Table

For Each oSh In ActivePresentation.Slides(2).Shapes

If oSh.Name = "EditableBox1" Then
oTarget_table.Cell(1, 2).Shape.TextFrame.TextRange.Text =
TheText(oSh)
End If

Next

ActivePresentation.SlideShowWindow.View.GotoSlide 3

End Sub


Now I just have to implement the other 65 text boxes and a second table!

Thanks,
Michael
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top