PDA

View Full Version : SaveAs on 2 Cell Based (Path)



devine78
01-31-2012, 11:43 AM
I have the following problem.

I want to save a document based on 2 cells.

Example:
Cell B5 = Amsterdam, Rotterdam, Utrecht, etc.
Cell B3 = Intern or Extern

So if someone fill in B5 for Amsterdam and B3 Extern then the must be saved in "\\server\Amsterdam\Extern" + Filename.xls.

I have found the following code witch provide some help

Private Sub CommandButton1_Click()
Application.DisplayAlerts = False
Application.EnableEvents = False
ActiveWorkbook.SaveAs Filename:= _
"\\server\" & "\" & Range("B5") & "\" & Range("B3") & "_" & Range("B1") & "_" & Range("B4") & ".xls" _
, FileFormat:=xlNormal, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False
Cancel = True
Application.DisplayAlerts = True
Application.EnableEvents = True
Unload Userform3
End Sub
The Text in B1 and B4 are using to name te file.

The Document will save in Amsterdam but doesn't go to Extern of Intern

I hope someone can help me.

Thanks for your time.

Greatings,

Fabian.

Bob Phillips
01-31-2012, 11:55 AM
Private Sub CommandButton1_Click()

Application.DisplayAlerts = False
Application.EnableEvents = False

ActiveWorkbook.SaveAs Filename:= _
"\\server\" & "\" & Range("B5") & "\" & Range("B3") & "\" & Range("B1") & "_" & Range("B4") & ".xls", _
FileFormat:=xlNormal, _
Password:="", _
WriteResPassword:="", _
ReadOnlyRecommended:=False, _
CreateBackup:=False

cancel = True

Application.DisplayAlerts = True
Application.EnableEvents = True

Unload Userform3
End Sub

devine78
01-31-2012, 12:11 PM
Thanks XLD you are the greatest, this work perfect. :bow: