Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel saving a Workbook to specific folder and prompt for name and subfolder

Status
Not open for further replies.

leo57

Programmer
Oct 28, 2013
33
0
0
US
The users version of Excel does not have Common Dialog Box or anything I have on my development PC.
issues at hand
1. not change the default "save-to" folder when they save other workbooks.
2. be able to save workbooks my VBA form creates into a specific "known" folder and then let the user choose customer sub folder below.
3. we can't install 3rd party tools.

Is there an API call to open the Windows Save Dialog?

 
As a starting point.

Code:
Function BrowseForFolder(Optional OpenAt As Variant, Optional Prompt As String) As String
     'Function purpose:  To Browse for a user selected folder.
     'If the "OpenAt" path is provided, open the browser at that directory
     'If the "Promp" is provided it will appear below the dialog header bar.
     'NOTE:  If invalid, it will open at the Desktop level
     
    Dim ShellApp As Object
     
     'Create a file browser window at the default folder
    Set ShellApp = CreateObject("Shell.Application"). _
    BrowseForFolder(0, Prompt, 0, OpenAt)
     
     'Set the folder to that selected.  (On error in case cancelled)
    On Error Resume Next
    BrowseForFolder = ShellApp.self.Path
    On Error GoTo 0
     
     'Destroy the Shell Application
    Set ShellApp = Nothing
     
     'Check for invalid or non-entries and send to the Invalid error
     'handler if found
     'Valid selections can begin L: (where L is a letter) or
     '\\ (as in \\servername\sharename.  All others are invalid
    Select Case Mid(BrowseForFolder, 2, 1)
    Case Is = ":"
        If Left(BrowseForFolder, 1) = ":" Then GoTo Invalid
    Case Is = "\"
        If Not Left(BrowseForFolder, 1) = "\" Then GoTo Invalid
    Case Else
        GoTo Invalid
    End Select
     
    Exit Function
     
Invalid:
     'If it was determined that the selection was invalid, set to False
    BrowseForFolder = False
     
End Function
 
Ok I found this >>> which does the same thing however it does not save anything

Sorry the one you have is not very user friendly either... I prefer the one in the attached image
so how do I make it save something?



 
hi,

Code:
'
    Dim FileToOpen
    FileToOpen = Application.GetOpenFilename("Excel Files (*.xls*), *.txt*")
    If FileToOpen <> False Then
        Workbooks.Open FileToOpen
    End If

Skip,
[sub]
[glasses]Just traded in my OLD subtlety...
for a NUance![tongue][/sub]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top