How JustAnswer Works:

  • Ask an Expert
    Experts are full of valuable knowledge and are ready to help with any question. Credentials confirmed by a Fortune 500 verification firm.
  • Get a Professional Answer
    Via email, text message, or notification as you wait on our site.
    Ask follow up questions if you need to.
  • 100% Satisfaction Guarantee
    Rate the answer you receive.

Ask Richard Your Own Question

Richard
Richard, Software Specialist
Category: Microsoft Office
Satisfied Customers: 31167
Experience:  Over 15 year experience resolving Microsoft Office Issues
32989067
Type Your Microsoft Office Question Here...
Richard is online now
A new question is answered every 9 seconds

I would like to have the code for creating a "save as" in a

This answer was rated:

I would like to have the code for creating a "save as" in a specific file folder on my server. Example our user is working on a spreadsheet, when they click the button, it opens the "save as" dialogue box, and the file folder location is a default, that I have setup on the server.

JBryan42 :

Welcome to JustAnswer. My name is XXXXX XXXXX I will be assisting you today. Please do not rate this session until it has been completed.

JBryan42 :

Are you asking how to replicate that functionality in your own code? Or a shortcut to activate that function? I'm not exactly sure what you're asking for.

Customer :

Sorry, I thought the question was going to Richard, who has been helping me recently. Here is the scenario, I have a spreadsheet open, that has a button control "Save as". I need to have the button perform a command, that opens the "Save as" dialogue box, but instead of the default path being, where the file was originated, I need to specify a file folder on my server, where I want the spreadsheet saved. Does that make any more sense?

Customer :

I do not have the code written for this command, so if I am understanding your question, I am looking for the shortcut to activate the button.

Customer :

Sorry, I thought the question was going to Richard, who has been helping me recently. Here is the scenario, I have a spreadsheet open, that has a button control "Save as". I need to have the button perform a command, that opens the "Save as" dialogue box, but instead of the default path being, where the file was originated, I need to specify a file folder on my server, where I want the spreadsheet saved. Does that make any more sense?





5:26 PM



I do not have the code written for this command, so if I am understanding your question, I am looking for the shortcut to activate the button.



JBryan42 :

Yes, that does make perfect sense. I can give you the code, but seeing that Richard has been helping you, I would prefer to let him have your question unless he opts out. Is that okay with you?

Customer :

That would be great, thank you.

JBryan42 :

No problem at all. Take care. And if Richard needs to opt out for any reason, I'll be happy to take over for him.

Customer :

Do I need to do anything on my end, or will the question be reassigned, so he will pick up where you and I have left it?

JBryan42 :

No need for you to do anything. He will pick it up at his end and you will get an email as soon as he does.

Hello,

I'm Rachel, and I’m a moderator for this topic. I sent your requested professional a message to follow up with you here, when they are back online.

If I can help further, please let me know. Thank you for your continued patience.

Best,

Rachel

Hi There,

The code for this is below

Sub t()


Dim IntialName As String
Dim fileSaveName As Variant

fileSaveName = Application.GetSaveAsFilename(InitialFileName:="C:\temp", _
fileFilter:="Excel Files (*.xls), *.xls")

End Sub


In my example, c:\temp is the save as location default

If you have any difficulties at all, please do not hesitate to let me know so I can assist you further

Thank you
Customer: replied 3 years ago.

The code opens up the correct folder, where I want to save to, but I need to keep the same file name, as originally opened. The code provided changes the name to whatever I put in quotations.

ok, then use my code below.

You set the file name for the variable FileName

Sub JA()

Dim IntialName As String
Dim fileSaveName As Variant
InitialDrive = "c:\test\"
Filename = "test.xlsx"

fileSaveName = Application.GetSaveAsFilename(InitialFileName:=InitialDrive & Filename, _
fileFilter:="Excel Files (*.xlsx), *.xlsx")


End Sub

Let me know if you have any difficulties please

Customer: replied 3 years ago.

I am not explaining very well. Let me try again:


Scenario: I open a file named: "Estimate_08272013.xlsm" from a folder on my local drive.


 


I make the necessary changes to the file, and then click on the command button_142


 


What I am looking for is:


1) I need to save it in a different folder, on my server - ***The code provided is doing this part**


2) I need the filename to be the same as the original "Estimate_08272013.xlsm" - ***The code as written, is currently changing the name - to a variable name, not the desired result***

Thanks,

Then use this code please

Sub JA()

Dim IntialName As String
Dim fileSaveName As Variant
Dim objClassOnly As Excel.Application

Set objClassOnly = GetObject(, "Excel.Application")

InitialDrive = "c:\test\"
Filename = objClassOnly.ActiveWorkbook.Name

fileSaveName = Application.GetSaveAsFilename(InitialFileName:=InitialDrive & Filename, _
fileFilter:="Excel Files (*.xlsx), *.xlsx")


End Sub



Richard, Software Specialist
Category: Microsoft Office
Satisfied Customers: 31167
Experience: Over 15 year experience resolving Microsoft Office Issues
Richard and 3 other Microsoft Office Specialists are ready to help you
Customer: replied 3 years ago.

Richard,


Sorry to bother you again, on this question, but I just noticed that this is not actually saving the file. When I click on the control button, it does open the "Save as" dialoque box, and has the proper name in the file name box, but when I click "Save" it closes the dialoque box, but is not saving the file, to the specified folder, and/or any other folder, for that matter. I have checked to ensure it was not saving to a temp folder, by chance.

Is it possible to look at your file?
Customer: replied 3 years ago.


Yes, if you will send me the link, again. Do you want me to upload the excel file?

yes, and tell me where the button is to run the code please

- Click the following link: http://www.wikisend.com
- Upload the file to that website
- Once it is uploaded, the resulting page will display a "File ID" number.
- Please, give me that "File ID Number"
Customer: replied 3 years ago.

File No. 522060

Can you tell me where the button is to run the code please

Its ok, I found it

 

Use this version please

 

<a href="http://ge.tt/4zy37uw/v/0?c">http://ge.tt/4zy37uw/v/0?c</a>

 

Let me know if you have any difficulties please
Customer: replied 3 years ago.

Attachments are only available to registered users.

Register Here

Attachments are only available to registered users.

Register Here

Attachments are only available to registered users.

Register Here
View Full Image

Attachments are only available to registered users.

Register Here

The editor took out some of the code, which is why I uploaded it for you.

http://ge.tt/4zy37uw/v/0?c
Customer: replied 3 years ago.


Richard, that code works, but I have realized a different issue with the code. As mentioned above, in this thread, the user needs to be able to open an existing file (example: 10013_Joe_Doe.xltm) and then click on the control button #142 which opens the "Save As" dialoque box, and the default file name, remains the same 10013_Joe_Doe.xltm.


 


As the code is currently written, that works, but what the user needs to be able to do, is modify the file name, by only changing the number associated with it (ie. 10013), they would change the file to 13157_Joe_Doe.xltm for example. As the code is written, it does not allow you to modify that name.


 


I have attached a flow chart of how the user would open the template file, modify it and save it as a quote, and then open the quote file, and modify it, click on the control button #142, and change the number on the file name, and save it in the desired file folder. Hope this makes sense, and is possible. Thanks

Attachments are only available to registered users.

Register Here

Attachments are only available to registered users.

Register Here

Attachments are only available to registered users.

Register Here
View Full Image

Attachments are only available to registered users.

Register Here

ok, for this requirement,

Change the code

ActiveWorkbook.SaveAs

to

ActiveWorkbook.SaveAs fileSaveName

then it saves it as the file name the users set in the save as box.

Customer: replied 3 years ago.

Richard I change the code, but receive a runtime error '1004, I have attached the screen shots below. Also, once I click on the control button, the first dialoque that comes up, is that "you cannot save a VB Project in a macro-free workbook" I noticed that the file extensions within the code, show .xlsm. I need to maintain the macro enabled workbook, when the user saves the file, but I do not want it saved as a macro-enabled template file.


Attachments are only available to registered users.

Register Here

Attachments are only available to registered users.

Register Here

Attachments are only available to registered users.

Register Here
View Full Image

Attachments are only available to registered users.

Register Here

Attachments are only available to registered users.

Register Here

Attachments are only available to registered users.

Register Here

Attachments are only available to registered users.

Register Here
View Full Image

Attachments are only available to registered users.

Register Here

Attachments are only available to registered users.

Register Here

Attachments are only available to registered users.

Register Here

Attachments are only available to registered users.

Register Here
View Full Image

Attachments are only available to registered users.

Register Here

You have to save it as a xlsm else it will stip out the Macros.

No way around this.

Use my version which works please

http://ge.tt/51yILvw/v/0?c