LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Bookmarks are deleted while generating MS word report from template.

Solved!
Go to solution

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.

0 Kudos
Message 1 of 23
(4,242 Views)

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. 

 

 

aputman
------------------
Heads up! NI has moved LabVIEW to a mandatory SaaS subscription policy, along with a big price increase. Make your voice heard.
Message 2 of 23
(4,229 Views)

Capture.PNG

aputman
------------------
Heads up! NI has moved LabVIEW to a mandatory SaaS subscription policy, along with a big price increase. Make your voice heard.
Message 3 of 23
(4,228 Views)

If you want to do it via Labview code, use the GetActiveXReferences VI:

 

Capture.PNG

aputman
------------------
Heads up! NI has moved LabVIEW to a mandatory SaaS subscription policy, along with a big price increase. Make your voice heard.
Message 4 of 23
(4,217 Views)

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:

Replace bookmark.png

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>   ---'


Message 5 of 23
(4,215 Views)

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)...

0 Kudos
Message 6 of 23
(4,210 Views)

@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:

Replace bookmark.png

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. 

aputman
------------------
Heads up! NI has moved LabVIEW to a mandatory SaaS subscription policy, along with a big price increase. Make your voice heard.
0 Kudos
Message 7 of 23
(4,208 Views)

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... 😞

0 Kudos
Message 8 of 23
(4,206 Views)

@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.

aputman
------------------
Heads up! NI has moved LabVIEW to a mandatory SaaS subscription policy, along with a big price increase. Make your voice heard.
0 Kudos
Message 9 of 23
(4,202 Views)

Attaching code saved for LabVIEW 2012.

0 Kudos
Message 10 of 23
(4,196 Views)