09-16-2015 04:35 PM
Hey guys,
Does anybody know how to search a Word document for a string and output the location at which the string was found?
The closest I can find is NI_Word.lvclass:Word Find & Replace (str).vi, which looks like this:
But it does the replacement using the Find command and doesn't output any range for the find.
To elaborate on my end goal:
I'm trying to append an array of pages to my report. The pages are identical except for the specific values within the page, so I'm loading them as a second Word document template and inserting that doc in to the main template. There are two images on each page, but the only way to insert an image in to the Word report is using a Bookmark or a Range. Unfortunately, you can't have duplicate bookmarks, so only one of the generated pages has the bookmarks if I try to use them. This is where I run in to problems and am hoping to use a known string on each page (from the template) to locate the spot where I need to insert the images.
Cheers
--------, Unofficial Forum Rules and Guidelines ,--------
'--- >The shortest distance between two nodes is a straight wire> ---'
Solved! Go to Solution.
09-16-2015 05:07 PM
That looks like VBA to me. If so, you can try making your own function, modified as follows:
Hope this helps.
Bob Schor
09-16-2015 05:44 PM
Thanks for the help, Bob. It looks like my home computer's Word install doesn't like LabVIEW, so I'll have to test the ^c method tomorrow. That might solve my problems as long as I can copy the images easy enough.
Cheers
--------, Unofficial Forum Rules and Guidelines ,--------
'--- >The shortest distance between two nodes is a straight wire> ---'
09-17-2015 10:18 AM - edited 09-17-2015 10:26 AM
That worked out great! It took some extra work to make the pasted image in-line (just like the text originally was). I haven't done much with the Report Gen Toolkit in the past, but I'm learning now that it's quite limited. Using the VBA methods to program Word myself gives a ton of flexibility and I like it a lot.
For others visiting this thread, here's what I've done:
I used this community post to copy the image to clipboard, the "^c" replace string to paste it, and this code to set text wrapping to InLine (also in the subVI included).
Thanks for the help, Bob!
Cheers
--------, Unofficial Forum Rules and Guidelines ,--------
'--- >The shortest distance between two nodes is a straight wire> ---'