+ Reply to Thread
Results 1 to 1 of 1

Save a file: Only need the path, don't want user to put in file name

Hybrid View

  1. #1
    Registered User
    Join Date
    05-08-2013
    Location
    Terre Haute, Indiana
    MS-Off Ver
    Excel 2010
    Posts
    13

    Save a file: Only need the path, don't want user to put in file name

    I'm currently working on a program that runs at the click of a button. Now that I am at the end of it, I need to save it where the user would like to save it - however - the end result is the product of synchronizing 2 files, and therefore will be assigned a name based on the subject's ID and which test they were doing.
    This is where I am at:

    Dim sav As Integer
    Dim file_name As Variant
    Dim sPath As String
    Dim sFile As String
    
    
    sPath = "C:\xxx\xxx\xxx\xxx\xxx\xxx\"
        
    'Define the file name: Subject Session synced.txt
    sFile = sSubID & " " & sSubSession & " synced.txt"
    sav = MsgBox("Would you like to save this file?", 4, "Save?")
    If sav = vbYes Then
      file_name = Application.GetSaveAsFilename( _
        Title:="Save As File Name")
    ActiveWorkbook.SaveAs Filename:=sPath & sFile, FileFormat:=xlTextWindows, CreateBackup:=False
    The sPath is set correctly - I modified it for confidentiality purposes.
    I need to be able to take control of the named file, I just want the user to be able navigate to where it will be placed.. Any way of achieving this?

    Currently, by entering anything at the desired location, it saves the correct file name, but I need this to be streamlined so I don't have techies saying "what the--WHERES MY FILE?"

    I'm not extremely familiar with VBA, but I'm kind of comfortable at this point, so this was the closest I could come to what I need with Google/Bing.

    Any suggestions?



    PS. Ideally, I don't want it to save over the current workbook. It's OK that it overwrites the information, but when it saves it changes "Sheet1" to the file sFile, which bugs the program for the next button click. Any inputs on this would be appreciated as well :d
    Last edited by skania; 05-10-2013 at 12:12 PM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1