Re: Path syntax in VBA

From: Jay Freedman (jay.freedman_at_verizon.net)
Date: 03/28/04


Date: Sat, 27 Mar 2004 21:43:58 -0500

And to answer your final question, no, you can't use the disk label in
the path at all -- Windows doesn't "understand" disk labels in paths
at all.

The best you can do is loop through all the drive letters; for each
letter, check whether there is a valid drive and, if so, what its
label is. When (and if) you find the label you expect the Zip disk to
have, then use the corresponding drive letter in the save path.

Here's the sample code from the VBA help topic on the VolumeName
method:

Sub ShowVolumeInfo(drvpath)
    Dim fs, d, s
    Set fs = CreateObject("Scripting.FileSystemObject")
    Set d =
fs.GetDrive(fs.GetDriveName(fs.GetAbsolutePathName(drvpath)))
    s = "Drive " & d.DriveLetter & ": - " & d.VolumeName
    MsgBox s
End Sub

If you need some help modifying this to do what I described, post a
reply in this thread.

"Jonathan West" <jwest@mvps.org> wrote:

>Hi Conan,
>
>If the template containing your macro code is on your Zip disk, then you can
>find the path of that template by getting the
>Application.MacroContainer.Path property. Take the first letter of that and
>you have your drive letter.
>
>--
>Regards
>Jonathan West - Word MVP
>http://www.multilinker.com
>Please reply to the newsgroup
>
>"Conan Kelly" <CTBarbarin@msn.com> wrote in message
>news:C87D0188-4A40-4076-A04C-DE718CF271AC@microsoft.com...
>> Hello all, I've set up some code in Word VBA to do some formatting and
>then save the document to a specific folder on my Zip disk. But the way
>I've done this is that I used the drive letter in the path. Well a problem
>there is if I use this macro at school, the drive letter for the Zip drive
>may not necessarily be the same as at home. Also, what if someone else’s
>Zip disk is in the drive.
>>
>> The question is can I use the disk label in the path instead of the drive
>letter, so it will automatically save to the correct drive and will check to
>see if the correct disk is in the drive? Will this work? If so, what is
>the syntax for the path then? Do I just replace the drive letter with the
>disk label like this: “Label:\folder\subfolder”?
>>
>> Thanks for any help anyone can provide,
>>
>> Conan Kelly
>>

--
Regards,
Jay Freedman
Microsoft Word MVP        FAQ: http://www.mvps.org/word


Relevant Pages

  • Re: Can I boot of an XP System disk, nested in a logical volume
    ... I'll boot of Partition Magic or some other kind of magic and fix it that-a-way. ... It's been a long time since I messed with partitions like this, but in the back of my head I have this fragment about boring registry hands-on editing, 'derived Disk ID's' and the 'Master Boot Sector' -- that's S as in 'Senile'. ... One reason for the drive letter change on cloned drives is to keep the parent drive hooked up the first time the clone is booted, being that the clone has the same Mount Manager database, and being that the Mount Manager *always* respects drive letter assignments, it will see the parent drive and its valid disk signature and assign the C: drive letter to the original C: drive, so there will be no C: letter available for the clone. ...
    (microsoft.public.windowsxp.basics)
  • Re: HD not being read
    ... click Disk Management. ... Right-click the disk you want to initialize, ... Change Drive Letter and Paths. ...
    (microsoft.public.windowsxp.hardware)
  • Re: Cloning windows 2000
    ... >> it has booted at least once and rebuilt its drive letter table. ... contents to this first partition. ... If you boot old-2K with the new drive in place and fresh partitions visible, ... old disk has that, so it might end up being 'H' or something else. ...
    (microsoft.public.win2000.general)
  • Re: Windows logon failure
    ... "Pegasus (MVP)" wrote: ... Temporarily install the problem disk as a slave disk in ... Find out the current drive letter for the bad disk's drive C:. ...
    (microsoft.public.windowsxp.general)
  • Re: Change Hard Drive & Optical Drive Letters
    ... Was Disk List checked before? ... Hard Drive 1 Drive Letter wasn't Changed. ... I have also, still in Disk Mgmt: rt click say Hard Drive 3, Properties, ... Assuming that your C drive is the one with WIndows installed on it, ...
    (microsoft.public.windowsxp.general)