PDA

View Full Version : Save as with Variable file location



gr8one68
02-23-2012, 01:56 PM
I'm new to the forum. I want to do a "save as" using the value in a cell and save it to a folder on our server. The folder will be variable. I have searched and found and modified a macro that will save the file as I want. I can't find how to tell it to navagate to the folder that I want. Here is the macro that I have to save the file from cell M6 plus a description.

Option Explicit
Sub SaveAsOpportunityNumber()
'Saves filename as value of m6

Dim newFile As String, fName As String
fName = Range("M6").Value
newFile = fName & "-Air Flow"
ActiveWorkbook.SaveAs Filename:=newFile

End Sub

Thanks in advance and I apologize if this has been covered before, I couldn't find it if it was.

p45cal
02-23-2012, 03:05 PM
I'm new to the forum. I want to do a "save as" using the value in a cell and save it to a folder on our server. The folder will be variable. I have searched and found and modified a macro that will save the file as I want. I can't find how to tell it to navagate to the folder that I want. Here is the macro that I have to save the file from cell M6 plus a description.

Option Explicit
Sub SaveAsOpportunityNumber()
'Saves filename as value of m6

Dim newFile As String, fName As String
fName = Range("M6").Value
newFile = fName & "-Air Flow"
ActiveWorkbook.SaveAs Filename:=newFile

End Sub

Thanks in advance and I apologize if this has been covered before, I couldn't find it if it was.The path is just part of the filename:
c:\docs and settings\john doe\important files\samplewb.xls
so if you have the path in another cell it could be:
newfile = Range("M5").value & Range("M6").value & "-Airflow"
making sure you have all the \ (backslash) characters where they should be.

gr8one68
02-23-2012, 03:32 PM
Thanks, I was hoping there was a way to have the box open up like when you go thorough the ribbon and hit "save as". Then I could navagate to the folder that I want the file saved in.

p45cal
02-23-2012, 04:59 PM
Oh there is, check out the getsaveasfilename method.

gr8one68
02-24-2012, 07:14 AM
Thanks, I have done a little research and it looks like this is exactly what I was looking for. I appreciate your help.