From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Add text string to a textbox that already exists in a Powerpoint Template

Solved!
Go to solution

So I am a novice to labview Activex for powerpoint. My goal is to use a powerpoint template that is already prefilled. I want to get the strings from a file and  open the powerpoint template to fill in the rest.  I followed the example in the link below but somehow when I get to the part where I want to select a method that would allow me to add the string I can't find any. the closest I found is ADDTEXTEFFECT but that doesnt work for me.. Any suggestion on how to add text to the existing textbox in the template with my own font type and size and position.

https://forums.ni.com/t5/LabVIEW/Add-jpg-to-Powerpoint-slides/td-p/1676338

0 Kudos
Message 1 of 17
(4,095 Views)

If you post your code somebody might be able to help you find the solution.

 

Ben64

0 Kudos
Message 2 of 17
(4,038 Views)
Solution
Accepted by topic author ritch_by_nature

OK, I took a look at the link and used the existing code as a starting point. You won't find any Add TextBox method because there is no such thing as aTextBox object in PP ActiveX. A TextBox is a Shape Object. To acces it use the Item method of the selected slide Shapes Object. For the Item index you can either use a numeric value (based on the order the shapes were added to the slide) or the Shape Object name (which I recommend).

 

When you create the template you can edit the Shape Object name in the Selection Pane (Home Tab, Editing Section, click the small arrow at the right of "select" and click Selection Pane ...).

 

Here is a code example:

PP Add Text to TextBox.png

Ben64

 

0 Kudos
Message 3 of 17
(4,029 Views)

Thanks for the reply. Well, my textbox is in my template already. I don't need to add another one. I would like add text string in it. My code is exactly the same as the one in the link up until where the author use the addpicture method. That's where I stopped because I would like to add strings instead. For example. If slide one in my template had a text box prefilled with "The name of the software is: ". I would to take a string from my file called "Labview". And add it to the textbox in my template and make it " The name of the software is: Labview". 

0 Kudos
Message 4 of 17
(4,010 Views)

It seems you didn't try my code because it does exactly what you want: add text to an existing TextBox.

 

Now if your TextBox contains prefilled text you can:

1- use the TextRange InsertAfter method to append text to the prefilled text or

2- read the TextBox text using the TextRange Text property, concatenate the result with the existing text and write it back again using the TextRange Text property.

 

Now if you try to use method 1 on an empty TextBox it will generate an error. So even if method 2 is a very little more work it will work without error even if the TextBox is initially empty.

 

Ben64

0 Kudos
Message 5 of 17
(4,007 Views)

ben64 a écrit :

It seems you didn't try my code because it does exactly what you want: add text to an existing TextBox.

 

Now if your TextBox contains prefilled text you can:

1- use the TextRange InsertAfter method to append text to the prefilled text or

2- read the TextBox text using the TextRange Text property, concatenate the result with the existing text and write it back again using the TextRange Text property.

 

Now if you try to use method 1 on an empty TextBox it will generate an error. So even if method 2 is a very little more work it will work without error even if the TextBox is initially empty.

 

Ben64


ERRATA: Method 1 (InsertAfter) will work even if the TexBox is initially empty. I used bad TextBox reference when I tried it and got error 97.

 

Ben64

0 Kudos
Message 6 of 17
(3,997 Views)

Thank you so much.. I will try the code and update you ..

0 Kudos
Message 7 of 17
(3,986 Views)

I am wondering after InsertAfter and use my text.. why can't I set the font I want.. ?

 

Update:

  Found it.. thanks

0 Kudos
Message 8 of 17
(3,963 Views)

So what If I am trying to add text string to a text box with bullets.. I dont seem to be able to write the text after the specific bullets in the textbox...

0 Kudos
Message 9 of 17
(3,955 Views)

Did you tried to concatenate a carriage return constant in front of the text you want to add?

 

Ben64

0 Kudos
Message 10 of 17
(3,951 Views)