Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 06-18-2012, 01:14 PM
missmr28 missmr28 is offline the saveas macro in excel 2010 is not transferring the macros to the new workbook Windows XP the saveas macro in excel 2010 is not transferring the macros to the new workbook Office 2010 32bit
Novice
the saveas macro in excel 2010 is not transferring the macros to the new workbook
 
Join Date: Jun 2012
Posts: 2
missmr28 is on a distinguished road
Default the saveas macro in excel 2010 is not transferring the macros to the new workbook

Hi
I have a workbook that has 3 macros and 3 worksheets. I created a saveas macro in order to transfer one worksheet to a different file and give it a filename that includes today's date. When I used the saveas macro, the worksheet was converted into a separate file in the correct destination and had the correct filename. But then, none of the 3 macros were present in this new file. Below is the code that I used. Can someone help me with figuring out why the macros didnt get transferred? Thanks!

Sub savemdrwork()

Thisdate = Range("F3").Value
If Thisdate = "" Then
MsgBox "Please Enter Today's Date", vbInformation
GoTo EndMacro
End If
Application.ScreenUpdating = False
ActiveSheet.Select
ActiveSheet.Copy
ThisFile = Range("F3").Value
ActiveSheet.SaveAs Filename:="E:\operator calibration files\mdr " & ThisFile & ".xlsm", FileFormat:= _
xlOpenXMLWorkbookMacroEnabled, CreateBackup:=False


Application.ScreenUpdating = True

'EndMacro: Range("F3").Select
End Sub
Reply With Quote
  #2  
Old 06-18-2012, 04:58 PM
macropod's Avatar
macropod macropod is offline the saveas macro in excel 2010 is not transferring the macros to the new workbook Windows 7 64bit the saveas macro in excel 2010 is not transferring the macros to the new workbook Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Your macro is only saving the worksheet, not the workbook. You should delete the unwanted worksheets, then save the remaining workbook with the new name.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 06-20-2012, 05:08 AM
missmr28 missmr28 is offline the saveas macro in excel 2010 is not transferring the macros to the new workbook Windows XP the saveas macro in excel 2010 is not transferring the macros to the new workbook Office 2010 32bit
Novice
the saveas macro in excel 2010 is not transferring the macros to the new workbook
 
Join Date: Jun 2012
Posts: 2
missmr28 is on a distinguished road
Default

Hi Paul..thank you!!! that worked! i was avoiding that strategy in the beginning because the unwanted macros remain in the saved workbook....but at the same time, if there is no code that can transfer macros of one worksheet, then this does end up being a wonderful option.
Thank you so much!!!
Reply With Quote
  #4  
Old 06-20-2012, 05:30 AM
macropod's Avatar
macropod macropod is offline the saveas macro in excel 2010 is not transferring the macros to the new workbook Windows 7 64bit the saveas macro in excel 2010 is not transferring the macros to the new workbook Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Hi missmr,

You can indeed transfer code from one workbook to another but, since the code's already in the workbook, it's more straightforward to do it this way. Any code attached to the worksheets you've deleted will also be deleted when you delete those sheets. All that might remain (apart from your saved worksheet's code) is code in userforms & other code modules, if you have them. Those, too, could be deleted via vba - but you'd have to give vba trusted access to the vba project object model - and that might not be advisable.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
Reply

Tags
excel 2010, macro, save as

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Range(Cell1,Cell2) Error on another workbook controlling some other workbook? tinfanide Excel Programming 1 02-09-2012 04:08 PM
Cutting and Pasting and Macro problems in Excel 2010 enkel Excel Programming 3 01-02-2012 10:15 PM
Mail with macro Excel 2010 santors71 Excel Programming 1 12-07-2011 06:34 AM
How do I assign a macro to a button when the macro is in my personal workbook? foolios Excel Programming 2 07-27-2011 02:41 PM
the saveas macro in excel 2010 is not transferring the macros to the new workbook macro to transfer data from one workbook to another workbook virsojour Excel Programming 5 02-01-2011 08:58 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 03:06 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft