ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Shell function (https://www.excelbanter.com/excel-programming/356157-shell-function.html)

Phil1982

Shell function
 
Through searching this site I've found out about the handy Shell function.

One thing that has dissapointed me about it though is that I expected you
could tell it to open files.......but it seems you can only tell it to open
the program

For example this didn't do what I'd hoped
Shell("C:\Music\Elvis.mp3", 1)

I hoped this would open winamp/win media player AND open the file


So does anyone know any tricks for opening non-Office files with VBA.
Preferably without having to use the Sendkeys function.

Thanks in advance

colonal18

Shell function
 
shell(""C:/program files/yourprogram" "C:/music/your mp3"")
this should work

"Phil1982" wrote:

Through searching this site I've found out about the handy Shell function.

One thing that has dissapointed me about it though is that I expected you
could tell it to open files.......but it seems you can only tell it to open
the program

For example this didn't do what I'd hoped
Shell("C:\Music\Elvis.mp3", 1)

I hoped this would open winamp/win media player AND open the file


So does anyone know any tricks for opening non-Office files with VBA.
Preferably without having to use the Sendkeys function.

Thanks in advance


Gary''s Student

Shell function
 
If you let shell use CMD, it will know the right application for your file:


Sub Macro1()
x = Shell("cmd.exe /c C:\musicguide.mp3", 1)
End Sub
--
Gary's Student


"Phil1982" wrote:

Through searching this site I've found out about the handy Shell function.

One thing that has dissapointed me about it though is that I expected you
could tell it to open files.......but it seems you can only tell it to open
the program

For example this didn't do what I'd hoped
Shell("C:\Music\Elvis.mp3", 1)

I hoped this would open winamp/win media player AND open the file


So does anyone know any tricks for opening non-Office files with VBA.
Preferably without having to use the Sendkeys function.

Thanks in advance



All times are GMT +1. The time now is 07:31 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com