0

I have an Excel macro in which a user can input their name via an input box. I then want to take the name they enter and use it as part of the file path to which the workbook is saved.

For example. If user enters their name as John, I want the file to be saved to F:\Workbooks\John\. If the user enters their name as Fred, I want the file to be saved to F:\Workbooks\Fred\. And so on.

I have a variable set up for name as a string. How should I write the code though?

Activeworkbook.saveas filename:"F:\Workbook\VARIABLE" <----how should I write the variable?

Thank you for any help.

Noel

2
Contributors
2
Replies
6
Views
6 Years
Discussion Span
Last Post by diegostix
0

Try:

Activeworkbook.saveas filename:"F:\Workbook\" & variable &"\" & ActiveWorkbook.Name

or if you already have the name "F:\Workbook\" & variable &"\MyWorkbook.xls"

Check first if directory exists, if not - create it.

Seba Sama

Edited by Seba Sama: n/a

0

Yep, creating the directories first solved my problem. I assumed the directories would automatically be created. Thank you so much for the help.

Noel

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.