Saving under a specific folder path

B

bjtrain83

I have an employee that is not familiar with the computer so when they open a
document and save it, it goes in the same area is was opened instead of his
personal folder. How do I make it where it automatically saves under his
folder path no matter what file he opens? If I can't do that, how do I make
a folder read-only, to where he can't save any documents under that folder?
 
T

tighe

a few answers with varying complexity. i am not very familiar with folder
settings to accomplish the other side of it.
1. talk to the employee. obviously this isn't a great solution, but if they
are struggling with this, maybe they should be mopping instead of creating
electronic documents.
2. make all documents templates so when the file is opened, a new document
is created. this will not force a save in their folder.
3. automate the save process, but since this is in the general section and
not programming this might be beyond what you expected to have to do.
disclaimer: i looked through the discusaion groups for most of this so thank
you Doug Robbins, and the word.mvps.org.
the more i try to explain the more complex it gets and i want to just refer
back to #1, but all of this can be adjusted to get in in the place you want
it including having the user rename it, but the directory is set.
A. save the documents as macro enabled template.
B. add a new procedure:

Public Sub Autonew()
Dim strUser As String
strUser = GetUserName
ActiveDocument.SaveAs "C:\Folders\" & strUser & "\" & Format(Date,
"MMDDYYY") & "somefilename.docx"
End Sub
C. the procedure will only work with the item here
http://word.mvps.org/FAQs/MacrosVBA/GetCurUserName.htm

hope this helps, i dont recieve notification of reply so i will try to see
if there is a reply.
 
G

Graham Mayor

The question concerned the saving of *existing* documents. You can find the
user's My Documents folder with the following macro function and then
automatically save the document into that folder using an autoopen macro in
the document template - as detailed at the end.

Public Declare Function SHGetSpecialFolderLocation _
Lib "shell32" (ByVal hWnd As Long, _
ByVal nFolder As Long, ppidl As Long) As Long

Public Declare Function SHGetPathFromIDList _
Lib "shell32" Alias "SHGetPathFromIDListA" _
(ByVal Pidl As Long, ByVal pszPath As String) As Long

Public Declare Sub CoTaskMemFree Lib "ole32" (ByVal pvoid As Long)

Public Const CSIDL_PERSONAL = &H5
Public Const CSIDL_DESKTOPDIRECTORY = &H10
Public Const MAX_PATH = 260
Public Const NOERROR = 0

Public Function SpecFolder(ByVal lngFolder As Long) As String
Dim lngPidlFound As Long
Dim lngFolderFound As Long
Dim lngPidl As Long
Dim strPath As String

strPath = Space(MAX_PATH)
lngPidlFound = SHGetSpecialFolderLocation(0, lngFolder, lngPidl)
If lngPidlFound = NOERROR Then
lngFolderFound = SHGetPathFromIDList(lngPidl, strPath)
If lngFolderFound Then
SpecFolder = Left$(strPath, _
InStr(1, strPath, vbNullChar) - 1)
End If
End If
CoTaskMemFree lngPidl
End Function

You can then incorporate this into the macro to save the document to that
folder eg

Sub AutoOpen()
With ActiveDocument
.SaveAs SpecFolder(CSIDL_PERSONAL) & Chr(92) & .name
End With
End Sub

http://www.gmayor.com/installing_macro.htm
--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top