![]() |
|
#5
|
||||
|
||||
|
One would assume that, given the corruption susceptibility relating to documents on flash drives being opened, I'd have thought a Document_Open macro would suffice. After all, if you've opened one from a fixed disk and you're saving to a flash drive, you're using Save As and I'd expect that's because that's what you intended to do. Intercepting saves is a lot more work, entailing an Application.Event handler, a 'ThisApplication' class module, and a DocumentBeforeSave macro. Even then, it won't trap the first SaveAs of a document on removable media. Still, if that's the route you want to take, in your document template you'll need:
• A standard code module containing: Code:
Dim wdAppClass As New ThisApplication Public Sub AutoExec() Set wdAppClass.wdApp = Word.Application End Sub • A class module named 'ThisApplication' containing: Code:
Public WithEvents wdApp As Word.Application
Private Sub wdApp_DocumentBeforeSave(ByVal Doc As Document, SaveAsUI As Boolean, Cancel As Boolean)
Dim DrvNm As String, DocNm As String, FSO As Object, Drv As Object
Set FSO = CreateObject("Scripting.FileSystemObject")
DrvNm = Left(Doc.Path, 1): DocNm = Split(Doc.Name, "do")(0)
For Each Drv In FSO.Drives
Select Case Drv.DriveType
Case 1 'Removable
If Drv.DriveLetter = DrvNm Then MsgBox DocNm & " is on Removable Drive " & Drv.DriveLetter: Exit For
Case 2 'Fixed
Case 3 'Network
Case 4 'CD-ROM
If Drv.DriveLetter = DrvNm Then MsgBox DocNm & " is on CD-ROM " & Drv.DriveLetter: Exit For
Case 5 'RAM-Disk
If Drv.DriveLetter = DrvNm Then MsgBox DocNm & " is on RAM-Disk " & Drv.DriveLetter: Exit For
End Select
Next Drv
End Sub
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
Macro to save as pdf with ability to choose save as folder
|
rvessio | Word VBA | 4 | 07-25-2016 12:37 PM |
Macro: How to get this macro to save to a specific location
|
LOUF | Word VBA | 1 | 12-07-2015 06:47 PM |
| Windows Media Player | Boo | Excel Programming | 0 | 04-28-2013 06:51 AM |
| Powerpoint save as WMV but media doesnt work. | hooney | PowerPoint | 0 | 02-21-2013 09:45 PM |
| Warn user/viewers if Font is not installed. | Rehnn | Word | 0 | 10-01-2009 06:26 AM |