Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 24
Default Saving a workbook using VBA

I am trying to set up my workbook to save any changes on pressing of a button.

I have created the macro, which is simple and contains the one following line

ActiveWorkbook.SaveAs Filename:=ActiveWorkbook.Name

This quite expectedly shows up a dialogue box asking if I want to overwrite
the existing file.

If I select Yes,then the file saves without any problem. However if I say
no or cancel then it produces the following error - Run-time error 1004,
application-defined or object defined error.

Ideally if I select no then I would want a dialogue that allows me to change
the filename, or if I select Cancel then I would like it to just return to
the current active worksheet.

Ive been playing with this for days and I am no closer to solving it.

Help anyone please
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default Saving a workbook using VBA

Try disabling alerts

Application.DisplayAlerts = False
ActiveWorkbook.SaveAs Filename:=ActiveWorkbook.Name
Application.DisplayAlerts = True

Mike

"Michael Hudston" wrote:

I am trying to set up my workbook to save any changes on pressing of a button.

I have created the macro, which is simple and contains the one following line

ActiveWorkbook.SaveAs Filename:=ActiveWorkbook.Name

This quite expectedly shows up a dialogue box asking if I want to overwrite
the existing file.

If I select Yes,then the file saves without any problem. However if I say
no or cancel then it produces the following error - Run-time error 1004,
application-defined or object defined error.

Ideally if I select no then I would want a dialogue that allows me to change
the filename, or if I select Cancel then I would like it to just return to
the current active worksheet.

Ive been playing with this for days and I am no closer to solving it.

Help anyone please

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,420
Default Saving a workbook using VBA

Why not just

ActiveWorkbook.Save

--
__________________________________
HTH

Bob

"Michael Hudston" wrote in
message ...
I am trying to set up my workbook to save any changes on pressing of a
button.

I have created the macro, which is simple and contains the one following
line

ActiveWorkbook.SaveAs Filename:=ActiveWorkbook.Name

This quite expectedly shows up a dialogue box asking if I want to
overwrite
the existing file.

If I select Yes,then the file saves without any problem. However if I say
no or cancel then it produces the following error - Run-time error 1004,
application-defined or object defined error.

Ideally if I select no then I would want a dialogue that allows me to
change
the filename, or if I select Cancel then I would like it to just return to
the current active worksheet.

Ive been playing with this for days and I am no closer to solving it.

Help anyone please



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 24
Default Saving a workbook using VBA

I have tried that bob, but makes no difference

"Bob Phillips" wrote:

Why not just

ActiveWorkbook.Save

--
__________________________________
HTH

Bob

"Michael Hudston" wrote in
message ...
I am trying to set up my workbook to save any changes on pressing of a
button.

I have created the macro, which is simple and contains the one following
line

ActiveWorkbook.SaveAs Filename:=ActiveWorkbook.Name

This quite expectedly shows up a dialogue box asking if I want to
overwrite
the existing file.

If I select Yes,then the file saves without any problem. However if I say
no or cancel then it produces the following error - Run-time error 1004,
application-defined or object defined error.

Ideally if I select no then I would want a dialogue that allows me to
change
the filename, or if I select Cancel then I would like it to just return to
the current active worksheet.

Ive been playing with this for days and I am no closer to solving it.

Help anyone please




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 24
Default Saving a workbook using VBA

Ok, Well this got rid of the error, however now I dont have any choice at
all whether it saves using the current name or allowing a re-name.

"Mike H" wrote:

Try disabling alerts

Application.DisplayAlerts = False
ActiveWorkbook.SaveAs Filename:=ActiveWorkbook.Name
Application.DisplayAlerts = True

Mike

"Michael Hudston" wrote:

I am trying to set up my workbook to save any changes on pressing of a button.

I have created the macro, which is simple and contains the one following line

ActiveWorkbook.SaveAs Filename:=ActiveWorkbook.Name

This quite expectedly shows up a dialogue box asking if I want to overwrite
the existing file.

If I select Yes,then the file saves without any problem. However if I say
no or cancel then it produces the following error - Run-time error 1004,
application-defined or object defined error.

Ideally if I select no then I would want a dialogue that allows me to change
the filename, or if I select Cancel then I would like it to just return to
the current active worksheet.

Ive been playing with this for days and I am no closer to solving it.

Help anyone please



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Saving a workbook using VBA

Hi Michael,

Just pop some error handling around your code:

On Error GoTo ErrorHandler:
ActiveWorkbook.SaveAs ActiveWorkbook.Name
ErrorHandler:

Thanks,

Steve
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
Color Changes When Saving 2007 Workbook as 97 - 2003 Workbook Don Excel Discussion (Misc queries) 0 April 20th 08 04:51 AM
Saving a sheet in a workbook as .csv but not changing workbook name gloryofbach[_4_] Excel Programming 3 October 30th 05 08:50 PM
saving workbook from URL Ajit Excel Programming 2 January 13th 05 06:15 PM
Saving a Workbook: Forcing User to Rename before Saving Rollin_Again[_6_] Excel Programming 5 April 16th 04 02:54 PM
Saving workbook gav meredith Excel Programming 2 April 14th 04 06:29 AM


All times are GMT +1. The time now is 01:58 AM.

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

About Us

"It's about Microsoft Excel"