Machsupport Forum

Mach Discussion => VB and the development of wizards => Topic started by: aircastle on February 16, 2012, 12:59:29 PM

Title: Start a .PDF from a button?
Post by: aircastle on February 16, 2012, 12:59:29 PM
From a button, is there a way to open a .PDF file for a user to read? It looks like MSM is supposed to do that, but it won't work for me. Any tips would be appreciated. Thank you.
Title: Re: Start a .PDF from a button?
Post by: iv-cnc on February 16, 2012, 01:29:43 PM
You can do the following (i don't know whether there is an easier way...)

create with notepad a file with extension .bat (executable with the name you want) eg. test.bat
write inside c:\test.pdf (your exact path!)

On your button write:
Shell ("c:\test.bat")


Hope it helps,
John
Title: Re: Start a .PDF from a button?
Post by: DaveCVI on February 16, 2012, 03:25:58 PM
John,
MSM has several buttons that open PDF files in order to display various documents.
If you're an MSM user having trouble with that, please let me know and I'll assist you with the MSM aspect of the issue.

If you are looking for general info on how to do that from a mach button, there is no built in ability in the mach APIs to do that.
MSM uses a call to windows to open pdf files.

Dave
Title: Re: Start a .PDF from a button?
Post by: iv-cnc on February 16, 2012, 03:44:59 PM
I didn't know that!

Very nice work you have done for MSM!
Title: Re: Start a .PDF from a button?
Post by: aircastle on February 16, 2012, 11:13:15 PM
Thanks for the tips, but I can't quite get it to work. I see a DOS window flash on the screen (so fast I can't read anything), but it won't run the PDF file. I am running Windows 7.

If this were to work, it seems like video files would work, too. Great for instructional videos for users.
Title: Re: Start a .PDF from a button?
Post by: iv-cnc on February 17, 2012, 12:02:24 PM
You are talking about MSM button or you used the .bat method and you see the black screen?
Title: Re: Start a .PDF from a button?
Post by: aircastle on February 17, 2012, 03:56:44 PM
I see the black DOS screen flash when using the .BAT method. Its too fast to see any possible error messages.
Title: Re: Start a .PDF from a button?
Post by: iv-cnc on February 17, 2012, 04:36:08 PM
I would prefer that you will solve the problem from the MSM buttons.

Allthough, to work with the idea of a .bat file,
the black screen that disappears is the executable and its not a problem that goes away.

Check your paths! and give permitions to the bat file. (right click > properties)
Open you pdf file by making default to open with a pdf reader software.

John
Title: Re: Start a .PDF from a button?
Post by: DaveCVI on February 17, 2012, 06:20:44 PM
Aircastle & iv-cnc,

I believe that there may be a tad of confusion here as to what is being asked about.

My understanding is that AirCastle, wants to learn how to open a PDF using a button in mach.
I'm guessing that he wants to do that as part of something he is working on.

Along the way, he appears to have noticed that our MachStdMill (MSM) product has buttons which open pdf documents.
The MSM buttons work fine and I don't think that Aircastle is saying there is a problem with MSM.
If I'm mistaken about that, and Aircastle is an MSM customer, then the thing to do is to drop into the MSM support forums and get some help (www.Calypsoventures.proboards.com (http://www.Calypsoventures.proboards.com))

I think the "quick blink" Aircastle describes is what he sees when using the batch file approach that iv-cnc suggested.
It's been some time since I ran a dos box batch file but that sounds like what I'd expect when shelling a batch file.
Shell opens the batch file, the batch file runs and then disappears. That happens quickly as batch files don't wait for any user input by default... so visually you see cmd DOS box flash open as a black window, the batch file executes (probably writing a few lines into the dos box that you don't get time to see) and then the cmd window closes - the visual result is quick black flash (as the cmd windows is a text window that is white text on black background).

Dave