07-06-2016 05:59 AM
I am attempting to pull images from a Microsoft Word document and use them within my Front Panel for a VI I am creating. Since there will be many images the idea is to just draw from the MS Word document and resize them within my front panel. However, I have never worked with 'pulling data' from a MS word document. Any ideas?
07-06-2016 07:06 AM
07-06-2016 07:23 AM
Hi Mike,
What I mean is copying the images out programmatically into a .JPEG file into a folder, which I would then draw the images from via LabVIEW. I have done as you suggested and looked at the MS forums, but the same problem I ran into is how to exactly implement their code, which is written in C#. The image file returned is a bitmap and my program requires .JPEG files.
I have attached the links for your reference in hopes that you may know of a way to execute this.
Manipulating Word Images Programmatically:
http://www.c-sharpcorner.com/uploadfile/codingexpert/how-to-manipulate-word-images-programmatically/
MS Forum Solution 1:
http://stackoverflow.com/questions/12287908/save-pictures-from-word-to-folder-c-sharp
MS Forum Solution 2:
http://stackoverflow.com/questions/7937487/extract-image-from-word-file
07-06-2016 08:01 AM
Well, this sounded interesting, so I also went looking, and found a remarkably simple method that actually works (I tested it). Here are the unbelievably-simple steps to take:
Here is a snippet:
Bob Schor
07-06-2016 08:16 AM - edited 07-06-2016 08:32 AM
Hi Bob,
Thank you for your snippet! I was curious as to whether or not you know of a solution that does not require a Third-Party library to do this? In my test run the VI skipped some of the images within the Doc File and did not create the folder as indicated.
07-06-2016 08:52 AM
@AllanIL wrote:Hi Bob,
Thank you for your snippet! I was curious as to whether or not you know of a solution that does not require a Third-Party library to do this? In my test run the VI skipped some of the images within the Doc File and did not create the folder as indicated.
Well, OpenG has been around for at least a decade, and is one of the first things I download and install from the NI Tools Network (VIPM, the VI Package Manager, is now bundled and installed by default with LabVIEW). It's pretty easy to write your own function to change the file extension from .docx (or .doc) to .zip. I'm so used to using OpenG, and knew about their Zip functions, that I forgot (or didn't realize) that LabVIEW also has an Unzip tool. See if that works for you -- you may need to do some of the work yourself.
Bob Schor
P.S. -- when you say "In my test run the VI skipped some of the images within the Doc File and did not create the folder as indicated", were you using the OpenG function? If so, can you attach a sample Word file (no incriminating images, please) that demonstrates this problem?
07-06-2016 09:37 AM
OK, I'll admit I'm too lazy to fiddle with the "change file extensions" VIs (I'm not a whiz with Regular Expressions), so I left the OpenG file name manipulation routines in, but did substitute LabVIEW's Zip reader. I created a directory based on the path and name of the Word/Zip file (by stripping off the extension, seeing if a directory already existed, otherwise creating it), then calling LabVIEW UnZip function, which returns an array of the unzipped files. Note that the images will show up in the word\media sub-folder, as before.
Here's the new Snippet (the old OpenG version is in the Diagram-Disabled case).
Bob Schor
07-06-2016 01:49 PM - edited 07-06-2016 01:50 PM
Look ma, no OpenG
So a couple of changes. I don't think making a copy is necessary, just perform the extraction on the .docx file where it is, and I used the native Get File Extension, which returns the file name and extension separately. Using this to perform an operation like convert file extension should be easy. Also how cool is it that this format exists? Totally makes stuff like a lot easier.
But I too am a huge fan of OpenG and highly suggest you install it. The license is BSD and open for use in commercial applications without cost.
Unofficial Forum Rules and Guidelines
Get going with G! - LabVIEW Wiki.
17 Part Blog on Automotive CAN bus. - Hooovahh - LabVIEW Overlord