Re: Path syntax in VBA
From: Jay Freedman (jay.freedman_at_verizon.net)
Date: 03/28/04
- Next message: Greg Maxey: "Re: Description in Macros dialog box gives wrong information by default"
- Previous message: Larry: "Re: Description in Macros dialog box gives wrong information by default"
- In reply to: Jonathan West: "Re: Path syntax in VBA"
- Messages sorted by: [ date ] [ thread ]
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
- Next message: Greg Maxey: "Re: Description in Macros dialog box gives wrong information by default"
- Previous message: Larry: "Re: Description in Macros dialog box gives wrong information by default"
- In reply to: Jonathan West: "Re: Path syntax in VBA"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|
|