LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Does anyone know how to display a word document in a window?

I have a pulldown menu that when selected I need to popup a document that is in either word format(.doc) or .pdf format.  Does anyone know how to do this.  I am using LabWindows/CVI version 6.
Thanks,
Donna 
0 Kudos
Message 1 of 9
(4,971 Views)

This function opens a document in its default viewer. This function has the same effect as double-clicking on a document in Windows Explorer.

You can register file types and their default viewers in Windows Explorer by selecting the File Types tab in the Folder Options dialog.

/*-------------------- Prototype ---------------------*/
int OpenDocumentInDefaultViewer (const char Document_Filename[],
                                 int Window_Display);

It is located in toolbox.fp
Thanks.
CVI 2010
LabVIEW 2011 SP1
Vision Builder AI 2011 SP1
0 Kudos
Message 2 of 9
(4,966 Views)
What value would I use for Window_Display?  Do I just use the OpenDocumentInDefaultViewer call in my callback, or is there anything else?
Thanks,
Donna
0 Kudos
Message 3 of 9
(4,963 Views)
Here is how you would use.
OpenDocumentInDefaultViewer ("C:\\myfile.doc", VAL_NO_ZOOM);
 
this will open myfile.doc in microsoft word with normal window. You can maximize or minimize window with different value of window display. See FP for help
Thanks.
CVI 2010
LabVIEW 2011 SP1
Vision Builder AI 2011 SP1
0 Kudos
Message 4 of 9
(4,957 Views)
Hello donna,
 
If you just want to display the contents of a Word document on a CVI panel, (using the Word 10.0 Object Model ActiveX controller), you can call the Word_OpenDocument function with the appropriate filename and panel handle. For instance:
int main (int argc, char *argv[])
{
 int worddocument;
 if (InitCVIRTE (0, argv, 0) == 0)
  return -1; /* out of memory */
 if ((panelHandle = LoadPanel (0, "Testing.uir", PANEL)) < 0)
  return -1;
 DisplayPanel (panelHandle);
 Word_OpenDocument ("c:\\Testing.doc", panelHandle, "", 0, 0,
        &worddocument, &uilerror);
 
 RunUserInterface ();
 DiscardPanel (panelHandle);
 return 0;
}
 
Another option would be to put an ActiveX Word document on your user interface by right clicking on a panel, selecting ActiveX, choosing Document from the ring control at the top of the resulting dialog, and then selecting Microsoft Word Document.  I haven't played around with Microsoft Word ActiveX containment, but the above procedure should work.
 
Hope that's what you're looking for.  Thanks.
Wendy L
LabWindows/CVI Developer Newsletter
0 Kudos
Message 5 of 9
(4,949 Views)

Wendy,

  I get an "undeclared identifier" compile error when I use Word_OpenDocument.  What #include am I missing?  I tried the "OpenDocumentInDefaultViewer method and it worked fine with one exception.  It pops up a message about whether I want to save or discard changes (changes weren't made I just scrolled) when I close the viewer.  I tried it both using .doc and .pdf formats.  So do you know if the Word_OpenDocument method will make it so that this popup will not occur?  I have the file as read-only so that doesn't help.

Thanks,

Donna

0 Kudos
Message 6 of 9
(4,933 Views)
Hello Donna,
 
If you want your word document or PDF file to open in Word or in Adobe Acrobat, you should use the OpenDocumentInDefaultViewer function as Sheetal suggested.  If instead, you want to display the contents of the Word document on a CVI panel, you can use the Word_OpenDocument function.  First, you will need to create a instrument driver for the Microsoft Word object model, then #include the associated header file (i.e. if you save the instrument as word.fp, you would need to add #include word.h at the top of your code).
 
Thanks. 
Wendy L
LabWindows/CVI Developer Newsletter
0 Kudos
Message 7 of 9
(4,927 Views)
I am using OpenDocumentInDefaultViewer function  and it works great.  However, I want to be able to specify the font in the window that displays the document.  Does anyone know how to specify the font for this call?
Thanks,
Donna
0 Kudos
Message 8 of 9
(4,753 Views)

Hi Donna

There is another solution, you can use:

system("winword.exe E:\\file.doc");

First is the name of the application you want to run it with, microsoft word in this case, and second the path of the file you want to open. There is also the LaunchExectuable(); the difference between them is that the first one doesn't return the control to your application until you close the document you have opened, with the second one you can still control your application while the word document is opened.

Juan

0 Kudos
Message 9 of 9
(4,741 Views)