Consulting

Results 1 to 5 of 5

Thread: Save as with Variable file location

  1. #1
    VBAX Newbie
    Joined
    Feb 2012
    Posts
    3
    Location

    Question Save as with Variable file location

    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.

  2. #2
    Knowledge Base Approver VBAX Wizard p45cal's Avatar
    Joined
    Oct 2005
    Location
    Surrey UK
    Posts
    5,876
    Quote Originally Posted by gr8one68
    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.
    p45cal
    Everyone: If I've helped and you can't be bothered to acknowledge it, I can't be bothered to look at further posts from you.

  3. #3
    VBAX Newbie
    Joined
    Feb 2012
    Posts
    3
    Location
    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.

  4. #4
    Knowledge Base Approver VBAX Wizard p45cal's Avatar
    Joined
    Oct 2005
    Location
    Surrey UK
    Posts
    5,876
    Oh there is, check out the getsaveasfilename method.
    p45cal
    Everyone: If I've helped and you can't be bothered to acknowledge it, I can't be bothered to look at further posts from you.

  5. #5
    VBAX Newbie
    Joined
    Feb 2012
    Posts
    3
    Location
    Thanks, I have done a little research and it looks like this is exactly what I was looking for. I appreciate your help.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •