+ Reply to Thread
Results 1 to 5 of 5

Shell - trouble with variables and quotes

  1. #1
    Registered User
    Join Date
    07-14-2010
    Location
    Snowmass, Colorado
    MS-Off Ver
    Excel 2007
    Posts
    30

    Shell - trouble with variables and quotes

    Hello,

    I'm having trouble with the Shell command from VBA.

    This line of code works:

    Please Login or Register  to view this content.
    But when I replace the hard coded paths with the variables, as below, it does not work and tells me "C:\Documents cannot be found" because I am not passing in any " around the parameters.

    Please Login or Register  to view this content.
    How do I pass in quotes around the path and parameter, as I'm doing in the example above???

    Thanks!
    BRL
    Last edited by brl8; 09-30-2010 at 12:05 PM.

  2. #2
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,168

    Re: Shell - trouble with variables and quotes

    These quote problems are stumpers and I've spent lots of time building them incorrectly.

    I've found that building a String Variable first, with all the correct values and then placing this in the call normally works.

    My second hint on putting quotes in these calls is to defind a Constant called QUOTE = Chr(34) and use & QUOTE & in building your strings.

  3. #3
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Shell - trouble with variables and quotes

    Double them as in your original:

    Please Login or Register  to view this content.
    Remember what the dormouse said
    Feed your head

  4. #4
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Shell - trouble with variables and quotes

    This is the way I do it:

    Please Login or Register  to view this content.



  5. #5
    Registered User
    Join Date
    07-14-2010
    Location
    Snowmass, Colorado
    MS-Off Ver
    Excel 2007
    Posts
    30

    Re: Shell - trouble with variables and quotes

    Awesome! Thanks all for the great suggestions.

    Here's what it took:

    Please Login or Register  to view this content.
    Thanks All.

+ 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