Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 93
Default Macro to "Save As"

Hi. I'm trying to create a macro to save as a new document, but I keep
getting a run-time error message when I run it. What it's supposed to do is
ask the user if they want to save it as a new document, if yes, then it
should go through the normal save as procedure (and I'm trying to point it to
a specific directory), if no, then the spreadsheet will just save. Here's
the code I have written. I'm no expert, I'm really just learning this as I
go, so please be gentle. :) Thanks!

If MsgBox("Do you want to Save this to a new file?" _
, vbYesNo, "Save As") = vbYes Then
ActiveWorkbook.SaveAs Filename:="S:\Sales\.xls"
Else
ActiveWorkbook.Save
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 8,856
Default Macro to "Save As"

You will have to change this bit:

Filename:="S:\Sales\.xls"

to something like:

Filename:="S:\Sales\your_name.xls"

Hope this helps.

Pete

On Mar 22, 11:39 am, Stephanie
wrote:
Hi. I'm trying to create a macro to save as a new document, but I keep
getting a run-time error message when I run it. What it's supposed to do is
ask the user if they want to save it as a new document, if yes, then it
should go through the normal save as procedure (and I'm trying to point it to
a specific directory), if no, then the spreadsheet will just save. Here's
the code I have written. I'm no expert, I'm really just learning this as I
go, so please be gentle. :) Thanks!

If MsgBox("Do you want to Save this to a new file?" _
, vbYesNo, "Save As") = vbYes Then
ActiveWorkbook.SaveAs Filename:="S:\Sales\.xls"
Else
ActiveWorkbook.Save



  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 93
Default Macro to "Save As"

Thanks Pete. That worked great, it's saving in the right place, but now it
saves as a document called "your name". Is there any way I can get it to
allow the user to actually name it themselves before it saves?

"Pete_UK" wrote:

You will have to change this bit:

Filename:="S:\Sales\.xls"

to something like:

Filename:="S:\Sales\your_name.xls"

Hope this helps.

Pete

On Mar 22, 11:39 am, Stephanie
wrote:
Hi. I'm trying to create a macro to save as a new document, but I keep
getting a run-time error message when I run it. What it's supposed to do is
ask the user if they want to save it as a new document, if yes, then it
should go through the normal save as procedure (and I'm trying to point it to
a specific directory), if no, then the spreadsheet will just save. Here's
the code I have written. I'm no expert, I'm really just learning this as I
go, so please be gentle. :) Thanks!

If MsgBox("Do you want to Save this to a new file?" _
, vbYesNo, "Save As") = vbYes Then
ActiveWorkbook.SaveAs Filename:="S:\Sales\.xls"
Else
ActiveWorkbook.Save




  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 3,101
Default Macro to "Save As"

Stephanie,

Try this

Sub saveit()
response = MsgBox("Do you want to Save this to a new file?" _
, vbYesNo, "Save As")
If response = 6 Then
Name = InputBox("Enter a Filename", "Get Filename")
If Name = "" Then End
ActiveWorkbook.SaveAs Filename:="C:\" & Name & ".xls"
End If
End Sub

"Stephanie" wrote:

Hi. I'm trying to create a macro to save as a new document, but I keep
getting a run-time error message when I run it. What it's supposed to do is
ask the user if they want to save it as a new document, if yes, then it
should go through the normal save as procedure (and I'm trying to point it to
a specific directory), if no, then the spreadsheet will just save. Here's
the code I have written. I'm no expert, I'm really just learning this as I
go, so please be gentle. :) Thanks!

If MsgBox("Do you want to Save this to a new file?" _
, vbYesNo, "Save As") = vbYes Then
ActiveWorkbook.SaveAs Filename:="S:\Sales\.xls"
Else
ActiveWorkbook.Save

  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 93
Default Macro to "Save As"

Thanks Mike. Between your post and Pete's I took the best of both and got it
to run the way I needed it to. Thank you both so much!

"Mike" wrote:

Stephanie,

Try this

Sub saveit()
response = MsgBox("Do you want to Save this to a new file?" _
, vbYesNo, "Save As")
If response = 6 Then
Name = InputBox("Enter a Filename", "Get Filename")
If Name = "" Then End
ActiveWorkbook.SaveAs Filename:="C:\" & Name & ".xls"
End If
End Sub

"Stephanie" wrote:

Hi. I'm trying to create a macro to save as a new document, but I keep
getting a run-time error message when I run it. What it's supposed to do is
ask the user if they want to save it as a new document, if yes, then it
should go through the normal save as procedure (and I'm trying to point it to
a specific directory), if no, then the spreadsheet will just save. Here's
the code I have written. I'm no expert, I'm really just learning this as I
go, so please be gentle. :) Thanks!

If MsgBox("Do you want to Save this to a new file?" _
, vbYesNo, "Save As") = vbYes Then
ActiveWorkbook.SaveAs Filename:="S:\Sales\.xls"
Else
ActiveWorkbook.Save



  #6   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 8,856
Default Macro to "Save As"

You're welcome, Stephanie, thanks for feeding back.

Pete

On Mar 22, 12:58 pm, Stephanie
wrote:
Thanks Mike. Between your post and Pete's I took the best of both and got it
to run the way I needed it to. Thank you both so much!



"Mike" wrote:
Stephanie,


Try this


Sub saveit()
response = MsgBox("Do you want to Save this to a new file?" _
, vbYesNo, "Save As")
If response = 6 Then
Name = InputBox("Enter a Filename", "Get Filename")
If Name = "" Then End
ActiveWorkbook.SaveAs Filename:="C:\" & Name & ".xls"
End If
End Sub


"Stephanie" wrote:


Hi. I'm trying to create a macro to save as a new document, but I keep
getting a run-time error message when I run it. What it's supposed to do is
ask the user if they want to save it as a new document, if yes, then it
should go through the normal save as procedure (and I'm trying to point it to
a specific directory), if no, then the spreadsheet will just save. Here's
the code I have written. I'm no expert, I'm really just learning this as I
go, so please be gentle. :) Thanks!


If MsgBox("Do you want to Save this to a new file?" _
, vbYesNo, "Save As") = vbYes Then
ActiveWorkbook.SaveAs Filename:="S:\Sales\.xls"
Else
ActiveWorkbook.Save- Hide quoted text -


- Show quoted text -



  #7   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 24
Default Macro to "Save As"

Is it possible to perform the exact same task but to either strip the macros
out of the newly saved documents? Or delete a "Save New Form" button that I
want to assign this macro to out of the new file? Or IDEALLY to delete 1
worksheet out of the workbook before saving the new one? (intended use is in
a "user friendly" form generating template)
--
THANKS!

Steve


"Pete_UK" wrote:

You're welcome, Stephanie, thanks for feeding back.

Pete

On Mar 22, 12:58 pm, Stephanie
wrote:
Thanks Mike. Between your post and Pete's I took the best of both and got it
to run the way I needed it to. Thank you both so much!



"Mike" wrote:
Stephanie,


Try this


Sub saveit()
response = MsgBox("Do you want to Save this to a new file?" _
, vbYesNo, "Save As")
If response = 6 Then
Name = InputBox("Enter a Filename", "Get Filename")
If Name = "" Then End
ActiveWorkbook.SaveAs Filename:="C:\" & Name & ".xls"
End If
End Sub


"Stephanie" wrote:


Hi. I'm trying to create a macro to save as a new document, but I keep
getting a run-time error message when I run it. What it's supposed to do is
ask the user if they want to save it as a new document, if yes, then it
should go through the normal save as procedure (and I'm trying to point it to
a specific directory), if no, then the spreadsheet will just save. Here's
the code I have written. I'm no expert, I'm really just learning this as I
go, so please be gentle. :) Thanks!


If MsgBox("Do you want to Save this to a new file?" _
, vbYesNo, "Save As") = vbYes Then
ActiveWorkbook.SaveAs Filename:="S:\Sales\.xls"
Else
ActiveWorkbook.Save- Hide quoted text -


- Show quoted text -




  #8   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 22,906
Default Macro to "Save As"

Steve

See Chip Pearson's site for deleting code from a workbook using VBA.

http://www.cpearson.com/excel/vbe.htm


Gord Dibben MS Excel MVP

On Wed, 2 May 2007 16:29:01 -0700, Steve_n_KC
wrote:

Is it possible to perform the exact same task but to either strip the macros
out of the newly saved documents? Or delete a "Save New Form" button that I
want to assign this macro to out of the new file? Or IDEALLY to delete 1
worksheet out of the workbook before saving the new one? (intended use is in
a "user friendly" form generating template)


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
"Save" and "Save As" options greyed out - "Save as Webpage" option Bill Excel Discussion (Misc queries) 0 January 16th 07 04:47 PM
Macro to concatenate into "B1" B2 thru B"x" based on new data in "Col A" Dennis Excel Discussion (Misc queries) 0 July 17th 06 02:38 PM
Running a macro "On Save" heski Excel Discussion (Misc queries) 2 May 18th 06 01:55 PM
"Save as" macro problems Angelique_Peach Excel Discussion (Misc queries) 0 April 25th 06 09:38 PM
Macro to create "path" for save Chris Excel Discussion (Misc queries) 4 March 15th 06 10:38 AM


All times are GMT +1. The time now is 04:48 AM.

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"