09-28-2020 12:36 PM
Hello,
I'm using the Report Generation Toolkit to create a printed label.
The toolkit is pulling data from an Excel worksheet and populating bookmark fields on a Word Template file.
Recently added a QR code to the label.
Following instructions from Microsoft here: https://support.microsoft.com/en-us/office/field-codes-mergebarcode-812fc43f-cb53-4782-8f9f-290ed08d...
Label is being created with the "curly brackets" and the MERGEBARCODE command still visible in the data field.
Instructions indicate that Ctrl+F9 must be used, and that typing the curly brackets will not work.
Is there a way to "toggle" the MS Word field codes in LabVIEW?
So far I have not found a way to do this.
Solved! Go to Solution.
09-28-2020 05:54 PM
Interesting. My generation called {} "braces". Of course, we called # "pound sign" and we didn't even have a term for @. 😉
09-28-2020 06:05 PM
I don't have a way to do it directly, but I've had problems where the RGT would be a big pain, but a Word/Excel macro would be super simple.
In those instances, I just load the data into Word/Excel from LabVIEW, then call a macro from within LabVIEW. It's not as flexible of course, but it's a massive pain to do much advanced plotting or formatting from the RGT. Maybe you can trigger a macro to do it if you can't find a LabVIEW-native way.
09-29-2020 08:09 AM
I think I may have found a way to do it.
Unfortunately I don't have the required version of MS Word installed on this PC. Waiting to hear the results of testing.
Here's the MS documentation for MergeBarcode:
I concatenated the brackets, command, and switches with my data. But the "field code" ended up in the field, not the barcode.
Found a post here:
https://forums.ni.com/t5/LabVIEW/How-to-update-fields-in-word/td-p/3207348
And then I found more MS documentation here:
https://docs.microsoft.com/en-us/office/vba/api/word.fields.toggleshowcodes
09-30-2020 07:17 AM
09-30-2020 08:32 AM
Hi Ben,
Thanks for your reply.
Yesterday the client scripted a macro in the Word template file, and we are having LabVIEW call that macro to show the Field Codes.
Private Sub Show_QRCode()
ActiveDocument.ActiveWindow.View.ShowFieldCodes = False
End Sub
If that does not work, I'll have something else to try now. Thanks!
10-02-2020 08:47 AM
Thanks Ben,
I ended up using DisplayBarcode (https://support.microsoft.com/en-us/office/field-codes-displaybarcode-6d81eade-762d-4b44-ae81-f9d3d9...)
Concatenated the command and switches with my data and popped it into a Bookmark on the report template. Then I call the macro in the template to toggle the field code.