Results 1 to 5 of 5
  1. #1
    3 Star Lounger
    Join Date
    May 2002
    Location
    Florence, Oregon, USA
    Posts
    209
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Open without a drive letter (VBA for Word2003)

    Windows XT sometimes looses the consecutiveness of the drive letters that it has assigned to mountable devices. If, for example, the drive letters available for mountable devices start with "I", and VBA code needs to open a file stored on a flash memory drive, the drive letter "I" has to be specified in its Open (or ChDrive) statement. Now, if for some irrelevant reason, the letter "I" has been assigned to another device, Windows, upon detecting the mounting of the flash drive, will assign it the letter "J". In this case the attempt to Open its file will fail. And, even after the two devices have been dismounted (using the proper procedures) and the PC rebooted, the flash device when mounted will still be assigned the letter "J".

    The only way to get the existing code to work is to manually tell Windows to change the drive letter "J" back to "I" as can be done in the following three steps:
    1. Right-click on My Computer and select Manage, then Disk Management.
    2. In the Computer Management dialog box, right-click on the representation of the J: drive.
    3. In the resultant context menu, select Change Drive Letter or Paths, and then from the drop-down list select "I".

    I know that rather tedious code can be written to scan all available drive letters looking for one that is assigned and that contains the required file, but even that will fail if a file of that name is held in more than one place. Therefore, three questions:

    1. Is there a way to issue a VBA Open statement without knowing the assigned drive letter, i.e. to tell Windows to find it?

    2. Is there a way, possibly via a call to an external API, to tell Windows to re-assign the drive letter?

    3. Is there a PDK (Program Developers Kit) available for Windows XT and/or Vista. I remember when coding for Windows 95 and earlier, an easily downloadable PDK was always on the Microsoft site filled with this type of information. If not, where can I find out this kind of stuff without bothering you?

    For those of you that will volunteer answers or comments, I thank you for your time and knowledge.

    John Littell

  2. #2
    Super Moderator
    Join Date
    Jan 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    3,852
    Thanks
    4
    Thanked 259 Times in 239 Posts

    Re: Open without a drive letter (VBA for Word2003)

    The best source of this kind of information that I know of is Microsoft's The Scripting Guys.

    This link shows how to detect any changes in drive mapping and may be useful

    This link appears to be another one I would investigate to work out which drive your removable disk has mapped to.

    An alternative workaround may be to map your removable drive to either drive A: or B: since you probably don't have two floppy disk drives. These ones won't be reused by anything so they should never change <img src=/S/evilgrin.gif border=0 alt=evilgrin width=15 height=15>
    Andrew Lockton, Chrysalis Design, Melbourne Australia

  3. #3
    Silver Lounger
    Join Date
    Jul 2001
    Location
    Ottawa, Ontario, Canada
    Posts
    1,609
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Open without a drive letter (VBA for Word2003)

    If you don't mind using a hammer to swat a fly; you could place a uniquely named path in each of your removeable drives, and look for that to detrermine the drive letter. Something like "?:ThispathidentifiesJLs<font color=red>Contract</font color=red>Drive ".
    Regards
    Don

  4. #4
    WS Lounge VIP rory's Avatar
    Join Date
    Dec 2000
    Location
    Burwash, East Sussex, United Kingdom
    Posts
    6,280
    Thanks
    3
    Thanked 191 Times in 177 Posts

    Re: Open without a drive letter (VBA for Word2003)

    Re your point 3, MSDN is the place to go. There are many SDKs available for download, including one for Windows Vista here. I assume that you mean Windows XP rather than XT and there should be an SDK for that available too.
    Regards,
    Rory

    Microsoft MVP - Excel

  5. #5
    3 Star Lounger
    Join Date
    May 2002
    Location
    Florence, Oregon, USA
    Posts
    209
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Open without a drive letter (VBA for Word2003)

    For replies received from Andrew, Don and Rory, I thank you. I will investigate all suggestions.

    And yes, Rory, I do mean XP. When your first IBM PC was the XT, it kinda' gets ingrained.

    John

Posting Permissions

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