Results 1 to 5 of 5
  1. #1
    4 Star Lounger
    Join Date
    Aug 2003
    Location
    Stroud, United Kingdom
    Posts
    548
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Browse for Folder Oddity (XP)

    Hi,

    can anyone shed any light on the fact that:

    Sub OpenFOlder()
    Dim strRoot As String, strBrowsedPath As String
    strRoot = "H:"
    strBrowsedPath = _
    CreateObject("Shell.Application").BrowseForFolder( 0, _
    "Select Folder for saving selected files", 0, strRoot).Items.Item.Path
    End Sub

    does NOT open the browse for folder box with the H: as the top node, (just has My Documents Folder selected)
    whereas:

    Sub OpenFOlder()
    Dim strBrowsedPath As String
    strBrowsedPath = _
    CreateObject("Shell.Application").BrowseForFolder( 0, _
    "Select Folder for saving selected files", 0, "H:").Items.Item.Path
    End Sub

    DOES ????
    Thanks,

    pmatz

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Browse for Folder Oddity (XP)

    It has something to do with passing arguments by value vs by reference. Try

    strBrowsedPath = _
    CreateObject("Shell.Application").BrowseForFolder( 0, _
    "Select Folder for saving selected files", 0, (strRoot)).Items.Item.Path

    to force passing strRoot by value.

  3. #3
    4 Star Lounger
    Join Date
    Aug 2003
    Location
    Stroud, United Kingdom
    Posts
    548
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Browse for Folder Oddity (XP)

    Thanks, that works now, thanks for the explaination too. Hope you are well Hans.

    <img src=/S/cheers.gif border=0 alt=cheers width=30 height=16>
    Thanks,

    pmatz

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Browse for Folder Oddity (XP)

    It's not a real explanation, at least not a good one... <img src=/S/sad.gif border=0 alt=sad width=15 height=15>

    I'm fine, by the way. You too, I hope.

  5. #5
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Yilgarn region of Toronto, Ontario
    Posts
    5,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Browse for Folder Oddity (XP)

    I would assume that Harold, who writes all the bad code at MS, knew how to cope with value descriptors, but knew not how to cope with Byref descriptors. Hence:<pre>If passed by value then
    I know how to deal with this
    else
    It's beyond me, I'll use the hard-coded My Documents trick. I know that one
    endif</pre>

    Either that or else he was working towards a deadline for a build/release.

    I'll add my thanks, and submit this for next year's Lounge Poetry Competition:
    "If in doubt, spread parentheses about"

Posting Permissions

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