Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > Excel VBA
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old September 6th, 2006, 05:00 AM
Authorized User
Join Date: Jul 2005
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Default Opening a folder from VB

I need to select manually the final subfolder to save target file.
How can I get visual basic to activate similar to "save as"-function and capture the final folder location (after opened) to a variable to get the target file saved into the final folder.

:):):) Axxess

Old September 6th, 2006, 05:10 AM
Friend of Wrox
Join Date: Jun 2003
Posts: 173
Thanks: 0
Thanked 3 Times in 3 Posts


Do you mean VBA or VB - I'm assuming you mean VBA (i.e. the language packaged with Excel). If its VB you're after then a slightly different answer will apply.

You do this by using Application.GetSaveAsFilename, which will open a Save As dialog box for the user to manually enter a save file name. The method returns a string which can then be used to save the file. An example would be as follows:

Sub TestSave()

Dim strNewFileName

    strNewFileName = Application.GetSaveAsFilename(InitialFileName:="Test.xls", Title:="Test Save Procedure")
    ThisWorkbook.SaveAs Filename:=strNewFileName

End Sub

Old September 6th, 2006, 05:49 AM
Authorized User
Join Date: Jul 2005
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts

THANKS A LOT maccas!!!

I got one step further with the project.
Tested and does exactly what you described.

:D:D:DAxxess (and also Eksel etc..)

Similar Threads
Thread Thread Starter Forum Replies Last Post
opening client side folder browser in c# sauravnimesh .NET Framework 2.0 4 November 21st, 2008 07:20 AM
emptying contents of temp folder using vb wingers Visual Basic 2008 Essentials 1 June 27th, 2008 10:38 AM
browsing for a folder, opening file am6019a VB How-To 5 February 21st, 2007 07:09 PM
opening a folder location JonniP Access 6 January 5th, 2007 09:01 AM
opening folder and return files treasacrowe Classic ASP Basics 3 February 18th, 2005 02:21 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.