forums Computer Tutorials Computer Help and Spyware Removal File DatabaseUninstall Database Windows Startup Programs Database Computer Resources Computer Glossary Forums Computer Help and Spyware Removal
 

Welcome Guest ( Log In | Click here to Register a free account now! )



Register a free account to unlock additional features at BleepingComputer.com
Welcome to Bleeping Computer, a free community where people like yourself come together to discuss and learn how to use their computers. Using the site is easy and fun. As a guest, you can browse and view the various discussions in the forums, but can not create a new topic or reply to an existing one unless you are logged in. Other benefits of registering an account are subscribing to topics and forums, creating a blog, and having no ads shown anywhere on the site.
Click here to Register a free account now! or read our Welcome Guide to learn how to use this site.

 
Reply to this topicStart new topic
> Vba Code For "save As", I'm Trying to Make a Shortcut
IrishLefty
post Apr 30 2008, 09:33 PM
Post #1


New Member
*

Group: Members
Posts: 4
Joined: 11-May 07
Member No.: 130,321



I want to put a button marked "SAVE AS" on my spreadsheet, and when it's clicked have the macro read the contents of Cell A1, add .xls to it and incorporate it in the Save As function. In other words, I need to speed up the Save As process such that all I have to do is type the name in Cell A1 and click the SAVE AS Button to save the document. Any ideas? I'm using Excel 2007.

Thank you

This post has been edited by IrishLefty: Apr 30 2008, 09:33 PM
Go to the top of the page
 
+Quote Post
adh_amit
post May 12 2008, 02:05 AM
Post #2


Member
**

Group: Members
Posts: 20
Joined: 8-January 06
Member No.: 49,633



Try this code:

Sub main()
fileI = ActiveSheet.Cells(1, 1).Value
FileN = fileI + ".xlsm"

ActiveWorkbook.SaveAs Filename:=FileN, FileFormat:=52

End Sub

Filefomat = 52 means file type is Open XML Workbook Macro Enabled. Excel2007 wont let you save the workbook in any other fomat since it contain a macro.

About the button part, I would suggest having a keyboard shortcut when you write this macro.e.g if Ctrl+T is your shortcut,
once you type Ctrl T, the current workbook will be saved to A1value.xlsm.

If you also want to close the file as soon as you save, add one more line to the code
activeworkbook.close savechanges:= true


Hope this helps.
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



Lo-Fi Version Time is now: 20th July 2008 - 08:47 AM


Advertise   |   About Us   |   Terms of Use   |   Privacy Policy   |   Contact Us   |   Site Map   |   Chat   |   Tutorials   |   Uninstall List
Discussion Forums   |   The Computer Glossary   |   Resources   |   RSS Feeds   |   Startups   |   The File Database   |   Malware Removal Guides

© 2003-2008 All Rights Reserved Bleeping Computer LLC.