LabVIEW Idea Exchange

cancel
Showing results for 
Search instead for 
Did you mean: 
David_L

Open a Document on Disk.vi Should be exposed on the palette

Status: New

Many people don't know, but there is a great VI in vi.lib called Open a Document on Disk.vi which does exactly as it explains.  If you feed it the location of any document (Word, Excel, HTML, PDF, ANYTHING!) it will open it with its default program on the computer.  Unfortunately this VI is hidden from the palette deep inside the vi.lib somewhere.  I think this should be placed on the palette as it can be very helpful in application development.

 

The VI is located at C:\Program Files\National Instruments\LabVIEW 2009\vi.lib\Platform\browser.llb\Open a Document on Disk.vi (default LabVIEW installation directory may be different) 

8 Comments
AristosQueue (NI)
NI Employee (retired)
Warning: Use of VIs not in the palettes may cause problems when upgrading LV as VIs not in the palettes may not exist in future versions of LabVIEW. To avoid problems, if you use VIs not in the palettes, copy the VI to another directory and use the copy in your work.
jlokanis
Active Participant

Why not just use the system exec.vi and pass it the file you want to open.  You may need to be more explicit about what app to use to open the file but it does work.

Or, you could make your own version of the vi.lib VI and include that in your app so NI cannot mess you up in the future if they change it's functionality. 

-John
------------------------
Certified LabVIEW Architect
David_L
Active Participant

Because you have to be more explicit about what app to use.  Also by doing this the cmd window pops up for a quick second to run the command and then closes.  To me it just doesn't look as good.

Why reinvent the wheel when it's already there and easy to use.  

And by putting it in the palette it would be available for people to know about and use.  It would prevent unnecessary extra work for everyone such as:

http://decibel.ni.com/content/docs/DOC-6843

and

http://decibel.ni.com/content/docs/DOC-6125 

and the code I was about to write using the System Exec VI but stopped when I heard about this one. 

Technico
Member

Hi,

 

I've just did a quick test with "Open a Document on Disk.vi" in LV8.5

and noticed this fails on opening *.xls- and *.doc-files containing spaces (with Office 2007 installed).

In the commandline no " " are added around the path+filename, I don't know if this is

still the case in LV 2009, but I think this should be fixed before adding to the palette.

 

EDIT: manually adding " " does not help either...

Message Edited by Technico on 12-23-2009 03:04 AM
mkabatek
Member

FYI, This VI does not exist in Labview Linux 2012, or @ least I cannot find it.

AristosQueue (NI)
NI Employee (retired)

mkabatek: Not a surprise. It's in the "Platform" subdirectory -- that subdirectory's contents are different on every platform. Linux may have some other VI that does something similar. Or it may never have been needed in order to support the public VIs.

 

For everyone else's info, I discovered that this VI does not open .png files. No idea why but you always get some sort of error. But it isn't a bug. This VI is not in the palettes, which means it does exactly what it needs to do to support the VIs that are in the palettes and nothing more than that. We'd probably have to fix this bug before it could be a candidate for exposing as a supported VI.

opejumeys
Member

In LabVIEW 2014, this VI uses the web browser to open the document, which is a kind of a pain since it forces the user to interact with the browser and choose to open from a pop up window with Open/Save/Save As options.

 

If you use system exec to call explorer.exe with the filepath, it will open the file with the default program via the command window, but does not require user interaction.

 

I use the following as the formatting for format to string with a path input:   cmd /c explorer.exe "%s"

AristosQueue (NI)
NI Employee (retired)

opejumey's solution only works on MS Windows, obviously. But a similar idea could probably be worked out for the other desktop platforms. Do real-time targets even have such a concept?