Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
No Name
 
Posts: n/a
Default Macro or VBA help

I would like to add a button to my spreadsheet that
opens "save as" and then after the user saves it it
reopens the original file.
Can anyone help me get that going?

Thanks.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Macro or VBA help

Hi,

It is not necessary to close the file and re-open it. Using SaveCopyAs will
save a copy to disk whilst keeping the original open.

Try attaching the following to your button:

Sub MyCopyAs()
Dim fName As Variant, Res As Variant
Res = MsgBox("Save a copy of this file?", vbYesNo)
If Res = vbYes Then
fName = Application.GetSaveAsFilename( _
fileFilter:="Microsoft Excel Files Files (*.xls), *.xls")
If fName < False Then
ActiveWorkbook.SaveCopyAs Filename:=fName
End If
End If
End Sub

---
Regards,
Norman


Try attaching the following macro to your button

wrote in message
...
I would like to add a button to my spreadsheet that
opens "save as" and then after the user saves it it
reopens the original file.
Can anyone help me get that going?

Thanks.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,120
Default Macro or VBA help

Here is some code to attach to the button


thisFile = ActiveWorkbook.Fullname
ans = MsgBox("Save file now?", vbYesNo)
If ans = vbYes Then
fileSaveName = Application.GetSaveAsFilename( _
fileFilter:="Microsoft Excle Files Files (*.xls), *.xls")
If fileSaveName < False Then
Activworkbook.SaveAs Filename:=fileSaveName
Workbooks.Open filename:= thisFile
End If
End If



--
HTH

-------

Bob Phillips
wrote in message
...
I would like to add a button to my spreadsheet that
opens "save as" and then after the user saves it it
reopens the original file.
Can anyone help me get that going?

Thanks.



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 118
Default Macro or VBA help

Here's code that make that work:
Sub SaveMe()
Dim wkbk As String
' grab name of open workbook
wkbk = ActiveWorkbook.FullName
' use built-in dialog to SaveAs
Application.Dialogs(xlDialogSaveAs).Show
' close saved workbook
ActiveWorkbook.Close
' reopen original workbook
Application.Workbooks.Open (wkbk)
End Sub

I think I would put it in the WorkSheet module for the sheet that's going to
have the button on it. Create your button and assign this macro to it.

Ed

wrote in message
...
I would like to add a button to my spreadsheet that
opens "save as" and then after the user saves it it
reopens the original file.
Can anyone help me get that going?

Thanks.



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro recorded... tabs & file names changed, macro hangs Steve Excel Worksheet Functions 3 October 30th 09 11:41 AM
need help to update macro to office 2007 macro enabled workbook jatman Excel Discussion (Misc queries) 1 December 14th 07 01:57 PM
Macro Help Needed - Excel 2007 - Print Macro with Auto Sort Gavin Excel Worksheet Functions 0 May 17th 07 01:20 PM
macro to delete entire rows when column A is blank ...a quick macro vikram Excel Programming 4 May 3rd 04 08:45 PM
Start Macro / Stop Macro / Restart Macro Pete[_13_] Excel Programming 2 November 21st 03 05:04 PM


All times are GMT +1. The time now is 09:19 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"