PC Review


Reply
Thread Tools Rate Thread

_Click action - syntax to open a file?

 
 
Lyndon Rickards
Guest
Posts: n/a
 
      10th Jan 2006
This must be too easy, if only it wasn't for
the vicodin...so please be patient with me ;->

Private Sub CommandButton1_Click()
system("pdfFile.pdf")
' or "docfile.doc"
' or "file.html"
End Sub

The external files will be distributed with the workbook, so I'm
not concerned about path relativity, though it would be nice to
be able to throw a msgbox just in case the file is not present in
the same folder as the workbook, or in the unlikely event
a suitable application is not available.

TIA - Lynn.
 
Reply With Quote
 
 
 
 
Dave Peterson
Guest
Posts: n/a
 
      10th Jan 2006
Option Explicit
Private Sub CommandButton1_Click()
dim teststr as string
dim myFileName as string

myfilename = "x:\pathtoyourfile\yourfile.ext")

teststr = ""
on error resume next
teststr = myfilename
on error goto 0
if teststr = "" then
msgbox "file not found
exit sub
end if

'take a look at Shell to see how to start other programs
'maybe something like:
Shell "Start " & chr(34) & myfilename & chr(34)

End Sub

Lyndon Rickards wrote:
>
> This must be too easy, if only it wasn't for
> the vicodin...so please be patient with me ;->
>
> Private Sub CommandButton1_Click()
> system("pdfFile.pdf")
> ' or "docfile.doc"
> ' or "file.html"
> End Sub
>
> The external files will be distributed with the workbook, so I'm
> not concerned about path relativity, though it would be nice to
> be able to throw a msgbox just in case the file is not present in
> the same folder as the workbook, or in the unlikely event
> a suitable application is not available.
>
> TIA - Lynn.


--

Dave Peterson
 
Reply With Quote
 
Lyndon Rickards
Guest
Posts: n/a
 
      10th Jan 2006
Thanks as always Dave. And I never would have guessed
chr(<anything>)...haven't used that since my early Basic
days - early 80's.

Geez how I wish Excel supported PerlScript!

Best - Lynn.

Dave Peterson wrote:
> Option Explicit
> Private Sub CommandButton1_Click()
> dim teststr as string
> dim myFileName as string
>
> myfilename = "x:\pathtoyourfile\yourfile.ext")
>
> teststr = ""
> on error resume next
> teststr = myfilename
> on error goto 0
> if teststr = "" then
> msgbox "file not found
> exit sub
> end if
>
> 'take a look at Shell to see how to start other programs
> 'maybe something like:
> Shell "Start " & chr(34) & myfilename & chr(34)
>
> End Sub
>
> Lyndon Rickards wrote:
>
>>This must be too easy, if only it wasn't for
>>the vicodin...so please be patient with me ;->
>>
>>Private Sub CommandButton1_Click()
>>system("pdfFile.pdf")
>>' or "docfile.doc"
>>' or "file.html"
>>End Sub
>>
>>The external files will be distributed with the workbook, so I'm
>>not concerned about path relativity, though it would be nice to
>>be able to throw a msgbox just in case the file is not present in
>>the same folder as the workbook, or in the unlikely event
>>a suitable application is not available.
>>
>>TIA - Lynn.

>
>

 
Reply With Quote
 
Dave Peterson
Guest
Posts: n/a
 
      10th Jan 2006
I find working with quotes sometimes confusing, but you could use this instead:

Shell "Start """ & myFilename & """"
instead of
Shell "Start " & chr(34) & myfilename & chr(34)





Lyndon Rickards wrote:
>
> Thanks as always Dave. And I never would have guessed
> chr(<anything>)...haven't used that since my early Basic
> days - early 80's.
>
> Geez how I wish Excel supported PerlScript!
>
> Best - Lynn.
>
> Dave Peterson wrote:
> > Option Explicit
> > Private Sub CommandButton1_Click()
> > dim teststr as string
> > dim myFileName as string
> >
> > myfilename = "x:\pathtoyourfile\yourfile.ext")
> >
> > teststr = ""
> > on error resume next
> > teststr = myfilename
> > on error goto 0
> > if teststr = "" then
> > msgbox "file not found
> > exit sub
> > end if
> >
> > 'take a look at Shell to see how to start other programs
> > 'maybe something like:
> > Shell "Start " & chr(34) & myfilename & chr(34)
> >
> > End Sub
> >
> > Lyndon Rickards wrote:
> >
> >>This must be too easy, if only it wasn't for
> >>the vicodin...so please be patient with me ;->
> >>
> >>Private Sub CommandButton1_Click()
> >>system("pdfFile.pdf")
> >>' or "docfile.doc"
> >>' or "file.html"
> >>End Sub
> >>
> >>The external files will be distributed with the workbook, so I'm
> >>not concerned about path relativity, though it would be nice to
> >>be able to throw a msgbox just in case the file is not present in
> >>the same folder as the workbook, or in the unlikely event
> >>a suitable application is not available.
> >>
> >>TIA - Lynn.

> >
> >


--

Dave Peterson
 
Reply With Quote
 
Lyndon Rickards
Guest
Posts: n/a
 
      11th Jan 2006
That's better ;-) For me, anyhow...

Dave Peterson wrote:
> I find working with quotes sometimes confusing, but you could use this instead:
>
> Shell "Start """ & myFilename & """"
> instead of
> Shell "Start " & chr(34) & myfilename & chr(34)
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
redirect file open action to another Leon_Amirreza Windows Vista File Management 0 25th Apr 2010 04:01 PM
How to insert Open File action in the IF Function? =?Utf-8?B?TWFqZXN0eQ==?= Microsoft Excel Misc 1 23rd Aug 2005 03:43 PM
default file action search instead of open drive Itech Windows XP General 1 15th Dec 2003 04:35 AM
long file names for open action John Morison Windows XP Basics 0 2nd Dec 2003 10:41 PM
runapp action to open excel file =?Utf-8?B?VGltIEphcmJvZQ==?= Microsoft Access Macros 1 10th Nov 2003 08:59 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:18 PM.