Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Jim Jim is offline
external usenet poster
 
Posts: 615
Default Saving Workbook Error-Plz help

I have the following code to automatically save the workbook

Private Sub CommandButton3_Click()
ThisWorkbook.Save
ThisWorkbook.Close
End Sub

I get this mesage box:
"A file named "myfilename.xls" already exists in this location, do you want
to replace it?"
I dont want this to come up. is there any way around this? Thanks
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 703
Default Saving Workbook Error-Plz help

After the .Save
ThisWorkbook.Saved = True


"Jim" wrote:

I have the following code to automatically save the workbook

Private Sub CommandButton3_Click()
ThisWorkbook.Save
ThisWorkbook.Close
End Sub

I get this mesage box:
"A file named "myfilename.xls" already exists in this location, do you want
to replace it?"
I dont want this to come up. is there any way around this? Thanks

  #3   Report Post  
Posted to microsoft.public.excel.programming
Jim Jim is offline
external usenet poster
 
Posts: 615
Default Saving Workbook Error-Plz help

That was the code in sheet 2, and the code in ThisWorkbook is as follows:

Private Sub Workbook_BeforeClose(Cancel As Boolean)
Sheets("Data").Activate
Columns("A:J").Select

If Selection.EntireColumn.Hidden < True Then
Selection.EntireColumn.Hidden = True
End If

sheetprot 'subroutine that protects all sheets
ThisWorkbook.Save
ThisWorkbook.Close
End Sub
  #4   Report Post  
Posted to microsoft.public.excel.programming
Jim Jim is offline
external usenet poster
 
Posts: 615
Default Saving Workbook Error-Plz help

Awesome, thanks charlie!!! works great

"Charlie" wrote:

After the .Save
ThisWorkbook.Saved = True


"Jim" wrote:

I have the following code to automatically save the workbook

Private Sub CommandButton3_Click()
ThisWorkbook.Save
ThisWorkbook.Close
End Sub

I get this mesage box:
"A file named "myfilename.xls" already exists in this location, do you want
to replace it?"
I dont want this to come up. is there any way around this? Thanks

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 245
Default Saving Workbook Error-Plz help

I think this is what your after

Private Sub Workbook_BeforeClose(Cancel As Boolean)
Application.DisplayAlerts = False
With ThisWorkbook
.Save
.Close
End With
Application.DisplayAlerts = True
End Sub

"Jim" wrote:

That was the code in sheet 2, and the code in ThisWorkbook is as follows:

Private Sub Workbook_BeforeClose(Cancel As Boolean)
Sheets("Data").Activate
Columns("A:J").Select

If Selection.EntireColumn.Hidden < True Then
Selection.EntireColumn.Hidden = True
End If

sheetprot 'subroutine that protects all sheets
ThisWorkbook.Save
ThisWorkbook.Close
End Sub

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
Excel 2007 - error saving file & error loading dll TinaF Excel Discussion (Misc queries) 0 July 1st 09 01:49 PM
Saving Excel 2003 Workbook in Excel 07 - Error Msg on Script obj WL Excel Discussion (Misc queries) 0 January 15th 08 06:20 PM
error message when saving excel workbook Deb Excel Discussion (Misc queries) 1 October 5th 05 08:26 PM
Saving a Workbook: Forcing User to Rename before Saving Rollin_Again[_6_] Excel Programming 5 April 16th 04 02:54 PM
ChartCalculate code causing error when saving workbook Pete McCosh[_5_] Excel Programming 0 February 19th 04 03:00 PM


All times are GMT +1. The time now is 08:44 PM.

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"