Save document to a different folder

S

Susan

this is a small public portion of a larger userform code. in the past
i've just let the documents save in the same folder where the userform
document is, then move it manually. wanted to try to make it save in
the correct place........... won't work - saves it in the same folder
as the document with the userform - even though when stepping thru &
using intellisense, all seems to be correct. i'm posting the code but
i know the word wrap is going to kill it & make it hard to read
(sorry).
variables are all declared elsewhere as public.
any ideas would be greatly appreciated!
thanks
susan

'===============================
Option Explicit

Public Sub MyPath()

Name1 = UserForm1.txtName1
Lastname = UserForm1.txtLastName
Year = UserForm1.txtYear

myFolder = Lastname & ", " & Name1

If UserForm1.chkLF.Value = True Then
PathName = "\\Snowbeltserver\Server\marilyn\My Documents\Apartments\"
_
& "LF & PL ELDERLY\Elderly Tenant Folders\LF515\" & myFolder
End If

If UserForm1.chkPL.Value = True Then
PathName = "\\Snowbeltserver\Server\marilyn\My Documents\Apartments\"
_
& "LF & PL ELDERLY\Elderly Tenant Folders\PL515\" & myFolder
End If

MyFileName = ActiveDocument.Name & "_" & Lastname & "-" & Year

ActiveDocument.SaveAs FileName:=MyFileName,
FileFormat:=wdFormatDocument

End Sub
 
D

DaveLett

Hi Susan,
It looks like you have done all of the work, but you just haven't specified
the path of the file. Change "FileName:=MyFileName" to "FileName:=PathName &
MyFileName"

HTH,
Dave
 
S

Susan

Dave -
rats, still won't work.

Public Sub MyPath()

Name1 = UserForm1.txtName1
Lastname = UserForm1.txtLastName
Year = UserForm1.txtYear

myFolder = Lastname & ", " & Name1

If UserForm1.chkLF.Value = True Then
PathName = "\\Snowbeltserver\Server\marilyn\My Documents\" _
& "LF & PL ELDERLY\Elderly Tenant Folders\LF 515\" & myFolder
End If

If UserForm1.chkPL.Value = True Then
PathName = "\\Snowbeltserver\Server\marilyn\My Documents\" _
& "LF & PL ELDERLY\Elderly Tenant Folders\PL 515\" & myFolder
End If

MyFileName = Lastname & "-" & Year & "_" & ActiveDocument.Name

ActiveDocument.SaveAs FileName:=PathName & MyFileName,
FileFormat:=wdFormatDocument

End Sub
'============================
i can't check the path name with intellisense, because it's too long -
it won't show the whole thing.
the document will save in the path that's quoted, but it won't open/go
into the folder variable myFolder.
using the fictious name of Charles Fox, i end up with, saved in the LF
515 folder,

Fox, CharlesFox-2009_nameofdocument.

when it should be saved in the Fox, Charles folder (which definitely
exists) as

Fox-2009_nameofdocument.

obviously i'm missing something else & i can't see the forest for the
trees.
any ideas? i'm using 2007 compatibility mode.
thanks a lot
susan
 
S

Susan

Dave -
rats, still won't work.

Public Sub MyPath()

Name1 = UserForm1.txtName1
Lastname = UserForm1.txtLastName
Year = UserForm1.txtYear

myFolder = Lastname & ", " & Name1

If UserForm1.chkLF.Value = True Then
PathName = "\\Snowbeltserver\Server\marilyn\My Documents\" _
         & "LF & PL ELDERLY\Elderly Tenant Folders\LF 515\" & myFolder
End If

If UserForm1.chkPL.Value = True Then
PathName = "\\Snowbeltserver\Server\marilyn\My Documents\" _
         & "LF & PL ELDERLY\Elderly Tenant Folders\PL 515\" & myFolder
End If

MyFileName = Lastname & "-" & Year & "_" & ActiveDocument.Name

ActiveDocument.SaveAs FileName:=PathName & MyFileName,
FileFormat:=wdFormatDocument

End Sub
'============================
i can't check the path name with intellisense, because it's too long -
it won't show the whole thing.
the document will save in the path that's quoted, but it won't open/go
into the folder variable myFolder.
using the fictious name of Charles Fox, i end up with, saved in the LF
515 folder,

Fox, CharlesFox-2009_nameofdocument.

when it should be saved in the Fox, Charles folder (which definitely
exists) as

Fox-2009_nameofdocument.

obviously i'm missing something else & i can't see the forest for the
trees.
any ideas?  i'm using 2007 compatibility mode.
thanks a lot
susan




- Show quoted text -
 
S

Susan

for the record, i figured it out using the excel newsgroup.

the last 3 lines should be:

MyPath = (PathName & "\" & myFolder)

MyFileName = Lastname & "-" & Year & "_" & ActiveDocument.Name

ActiveDocument.SaveAs FileName:=MyPath & "\" & MyFileName,
FileFormat:=wdFormatDocument

hope it helps somebody in the future!
:)
susan
 

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