06-27-2016 10:40 AM
I was trying to create a MS Word report, using a template and observed that bookmarks from the template are deleted on updating that field with text.
Is this normal?
If so, please help me with, how can we retain the bookmarks while creating a MS word report. The actual requirement is some of the fields of a report can be updated with new data hence bookmark must be present.
I'm attaching my prototype code (LabVIEW 2013) here.
Thanks a lot.
Solved! Go to Solution.
06-27-2016 11:37 AM
Sorry I can't open your file but here is what I think is probably happening. Bookmarks are simply a location in the document. If you associate a bookmark with a field, going to that bookmark selects the field. Try it for yourself. Click CTRL+G and select a bookmark to go to that is associated with a field. It will select the field. Then when you insert text via Labview, the field is overwritten with the text, same thing that would happen if you Goto a field and start typing.
What you need to do is Restrict Editing on your template file to only allowing Filling in Forms. This should fix your problem.
06-27-2016 11:42 AM
06-27-2016 11:54 AM
If you want to do it via Labview code, use the GetActiveXReferences VI:
06-27-2016 11:55 AM - edited 06-27-2016 11:57 AM
Aputman is correct. The Report Gen VI uses Word_Insert_Text.vi to replace the bookmark with your text, which gets rid of the bookmark. If you dive in to the Report Gen VIs, you will see this. Another workaround you could use is to assign the bookmark once again after the VI replaces it. Here is what that would look like in the Word_Insert_Text Vi:
I tested this with your VI and document and it works. If you alter the Report Generation Toolkit VI, make sure to Save As with some extra suffix, so you don't change the functionality of other VIs.
Cheers
--------, Unofficial Forum Rules and Guidelines ,--------
'--- >The shortest distance between two nodes is a straight wire> ---'
06-27-2016 12:00 PM
Hey aputman,
Thanks for the reply.
Let me reprase the issue that I'm experiencing. I've performed following:
1. Created a document with BOOKMARKS and saved it as a TEMPLATE.
2. Using LabVIEW code, I populated the report with some data, using BOOKMARKS as where to put what data.
3. Saved the populated report, named it (say) Report.doc.
4. Now this time, instead of TEMPLATE, I opened Report.doc file, with intention of replacing the text with some other data.....
at step#4, I'm getting error -41110... on further investigation I found that the BOOKMARKS weren't available on the report that I created (Report.doc)...
06-27-2016 12:04 PM
@James.M wrote:Aputman is correct. The Report Gen VI uses Word_Insert_Text.vi to replace the bookmark with your text, which gets rid of the bookmark. If you dive in to the Report Gen VIs, you will see this. Another workaround you could use is to assign the bookmark once again after the VI replaces it. Here is what that would look like in the Word_Insert_Text Vi:
I tested this with your VI and document and it works. If you alter the Report Generation Toolkit VI, make sure to Save As with some extra suffix, so you don't change the functionality of other VIs.
James, I don't think this will do what the OP wants (if I understand the requirements properly). A bookmark is not the same as a field. If the OP still wants the field to be editable with the bookmark in place, they will need to restrict editing to form fill only.
06-27-2016 12:08 PM - edited 06-27-2016 12:10 PM
Dear aputman and James.Morris,
Please check the LabVIEW code and teample that I've attached and you'll understand the issue that I'm facing.
Edited:
@aputman: I tried restricting the doc/template editing to form fill only but no help... 😞
06-27-2016 12:10 PM
@scofield wrote:Dear aputman and James.Morris,
Please check the LabVIEW code and teample that I've attached and you'll understand the issue that I'm facing.
As I stated, I can't open your VI. If you can save as 2012, I'll take a look.
06-27-2016 12:12 PM
Attaching code saved for LabVIEW 2012.