View Single Post
  #14   Report Post  
Posted to microsoft.public.excel.programming
Peter T[_7_] Peter T[_7_] is offline
external usenet poster
 
Posts: 162
Default Default browser?


"GS" wrote in message
but thinking this function isn't really necessary if you have a list of
executable filenames


Uh.., I stand corrected if one doesn't already have a procedure for
creating files! Since I already have this the 'Kill' statement would be
included in the 'GetExecutable$()' function so it runs stand-alone and
callable to return the info.


Gary, not sure I follow but what I posted was only intended as example,
adapt as required, typically as a function to receive an extension and
return the exe name possibly with its path. If you know the location of a
file with the extension no need to make a dummy, or maybe adapt to create a
dummy optionally if a known *.ext doesn't exist (and kill it of course!).
All in the one function or two as I posted is only style.

Charlotte, although it's worked 100% in your testing it can fail, not least
if there is no file association (though unlikely not to have a default
browser). Return values 1 to 31 are error codes to inform what the problem
was and there's a list out there somewhere if you search FindExecutable.
Don't forget to adapt for 64bit if necessary including the return var as
LongPtr.

You didn't say what the objective was but if to launch the default browser
with a given file simply use ShellExecute.

Regards,
Peter T