+ Reply to Thread
Results 1 to 4 of 4

Using Shell to open files with more than one word in their name

  1. #1
    Phil1982
    Guest

    Using Shell to open files with more than one word in their name

    Thank you to colonal18 and Gary's Student, through combining your advice I'v
    managed to come up with this code which opens the file who's name is in the
    current cell and opens it with the application I want.

    Sub playfiles()
    Dim PlayFile
    PlayFile = Shell("C:\Program Files\Winamp\winamp.exe C:\MP3\" &
    ActiveCell.Value, 1)
    End Sub

    The only problem is it doesn't work on files with more than one word in
    their name. If the cell I have selected has a file with 2 words in its name
    e.g. Happy Birthday.mp3 - it opens WinAmp and treats it as if it was being
    asked to open 2 files(one called Happy, one called Birthday) neither of which
    exist.

    The obvious (and impractical) way around this is to manually rename every
    file with underscores_instead_of spaces.

    Does anyone know a better solution?


    Thanks

    Phil

  2. #2
    Phil1982
    Guest

    RE: Using Shell to open files with more than one word in their nam

    Could someone say please what the single quote ' means or does?

    So that I can think where I wise to put it


    Thanks

    "Tom Ogilvy" wrote:

    > play around with the single quote
    >
    > Sub playfiles()
    > Dim PlayFile
    > PlayFile = Shell("'C:\Program Files\Winamp\winamp.exe C:\MP3\" &
    > ActiveCell.Value & "'", 1)
    > End Sub
    >
    > --
    > Regards,
    > Tom Ogilvy
    >
    >
    >
    > "Phil1982" wrote:
    >
    > > Thank you to colonal18 and Gary's Student, through combining your advice I'v
    > > managed to come up with this code which opens the file who's name is in the
    > > current cell and opens it with the application I want.
    > >
    > > Sub playfiles()
    > > Dim PlayFile
    > > PlayFile = Shell("C:\Program Files\Winamp\winamp.exe C:\MP3\" &
    > > ActiveCell.Value, 1)
    > > End Sub
    > >
    > > The only problem is it doesn't work on files with more than one word in
    > > their name. If the cell I have selected has a file with 2 words in its name
    > > e.g. Happy Birthday.mp3 - it opens WinAmp and treats it as if it was being
    > > asked to open 2 files(one called Happy, one called Birthday) neither of which
    > > exist.
    > >
    > > The obvious (and impractical) way around this is to manually rename every
    > > file with underscores_instead_of spaces.
    > >
    > > Does anyone know a better solution?
    > >
    > >
    > > Thanks
    > >
    > > Phil


  3. #3
    Tom Ogilvy
    Guest

    RE: Using Shell to open files with more than one word in their nam

    the single quote didn't work. I don't have winamp, but using windows media
    player this worked for me.


    Sub playfiles()
    Dim PlayFile
    PlayFile = Shell( _
    "C:\Program Files\Windows Media Player\wmplayer.exe ""C:\MP3\" & _
    ActiveCell.Value & """", 1)
    End Sub

    the active cell contained Fun ky.mp3

    with a space in it.

    so for you it would be

    Sub playfiles()
    Dim PlayFile
    PlayFile = Shell( _
    "C:\Program Files\Winamp\winamp.exe ""C:\MP3\" &
    ActiveCell.Value & """", 1)
    End Sub

    --
    Regards,
    Tom Ogilvy


    "Phil1982" wrote:

    > Could someone say please what the single quote ' means or does?
    >
    > So that I can think where I wise to put it
    >
    >
    > Thanks
    >
    > "Tom Ogilvy" wrote:
    >
    > > play around with the single quote
    > >
    > > Sub playfiles()
    > > Dim PlayFile
    > > PlayFile = Shell("'C:\Program Files\Winamp\winamp.exe C:\MP3\" &
    > > ActiveCell.Value & "'", 1)
    > > End Sub
    > >
    > > --
    > > Regards,
    > > Tom Ogilvy
    > >
    > >
    > >
    > > "Phil1982" wrote:
    > >
    > > > Thank you to colonal18 and Gary's Student, through combining your advice I'v
    > > > managed to come up with this code which opens the file who's name is in the
    > > > current cell and opens it with the application I want.
    > > >
    > > > Sub playfiles()
    > > > Dim PlayFile
    > > > PlayFile = Shell("C:\Program Files\Winamp\winamp.exe C:\MP3\" &
    > > > ActiveCell.Value, 1)
    > > > End Sub
    > > >
    > > > The only problem is it doesn't work on files with more than one word in
    > > > their name. If the cell I have selected has a file with 2 words in its name
    > > > e.g. Happy Birthday.mp3 - it opens WinAmp and treats it as if it was being
    > > > asked to open 2 files(one called Happy, one called Birthday) neither of which
    > > > exist.
    > > >
    > > > The obvious (and impractical) way around this is to manually rename every
    > > > file with underscores_instead_of spaces.
    > > >
    > > > Does anyone know a better solution?
    > > >
    > > >
    > > > Thanks
    > > >
    > > > Phil


  4. #4
    Phil1982
    Guest

    RE: Using Shell to open files with more than one word in their nam

    Yes! Thanks Tom

    Mission accomplished!

    I'd love to understand the syntax of that so that I can adjust it for other
    tasks, but it looks to complex for me!


    Cheers

    Phil

    "Tom Ogilvy" wrote:

    > the single quote didn't work. I don't have winamp, but using windows media
    > player this worked for me.
    >
    >
    > Sub playfiles()
    > Dim PlayFile
    > PlayFile = Shell( _
    > "C:\Program Files\Windows Media Player\wmplayer.exe ""C:\MP3\" & _
    > ActiveCell.Value & """", 1)
    > End Sub
    >
    > the active cell contained Fun ky.mp3
    >
    > with a space in it.
    >
    > so for you it would be
    >
    > Sub playfiles()
    > Dim PlayFile
    > PlayFile = Shell( _
    > "C:\Program Files\Winamp\winamp.exe ""C:\MP3\" &
    > ActiveCell.Value & """", 1)
    > End Sub
    >
    > --
    > Regards,
    > Tom Ogilvy
    >
    >
    > "Phil1982" wrote:
    >
    > > Could someone say please what the single quote ' means or does?
    > >
    > > So that I can think where I wise to put it
    > >
    > >
    > > Thanks
    > >
    > > "Tom Ogilvy" wrote:
    > >
    > > > play around with the single quote
    > > >
    > > > Sub playfiles()
    > > > Dim PlayFile
    > > > PlayFile = Shell("'C:\Program Files\Winamp\winamp.exe C:\MP3\" &
    > > > ActiveCell.Value & "'", 1)
    > > > End Sub
    > > >
    > > > --
    > > > Regards,
    > > > Tom Ogilvy
    > > >
    > > >
    > > >
    > > > "Phil1982" wrote:
    > > >
    > > > > Thank you to colonal18 and Gary's Student, through combining your advice I'v
    > > > > managed to come up with this code which opens the file who's name is in the
    > > > > current cell and opens it with the application I want.
    > > > >
    > > > > Sub playfiles()
    > > > > Dim PlayFile
    > > > > PlayFile = Shell("C:\Program Files\Winamp\winamp.exe C:\MP3\" &
    > > > > ActiveCell.Value, 1)
    > > > > End Sub
    > > > >
    > > > > The only problem is it doesn't work on files with more than one word in
    > > > > their name. If the cell I have selected has a file with 2 words in its name
    > > > > e.g. Happy Birthday.mp3 - it opens WinAmp and treats it as if it was being
    > > > > asked to open 2 files(one called Happy, one called Birthday) neither of which
    > > > > exist.
    > > > >
    > > > > The obvious (and impractical) way around this is to manually rename every
    > > > > file with underscores_instead_of spaces.
    > > > >
    > > > > Does anyone know a better solution?
    > > > >
    > > > >
    > > > > Thanks
    > > > >
    > > > > Phil


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1