Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Save As behaviour

Hope someone can help, as is usually the case I'm probably missing
something really obvious!

I have a button on a form that I want to save the last contents of the
current workbook to a specific name as follows...

Private Sub cbEnd_Click()

Dim fname As String

fname = "Last end status"
ActiveWorkbook.SaveAs Filename:=fname,
ConflictResolution:=xlLocalSessionChanges
Unload Me

End Sub

I have another subroutine, part of which does exactly the same thing but
at specific periods as data changes...

fname = "Status at" + Str(vaNextClock) + " secs"

vaCurrClock = vaCurrClock Mod 5
vaNextClock = vaNextClock Mod 5

If vaCurrClock < vaNextClock And vaNextClock = 0 Then
ActiveWorkbook.SaveAs Filename:=fname,
ConflictResolution:=xlLocalSessionChanges
End If

My issue is that the second piece of code works fine but the first piece
always shows the confirm dialog box, does anyone have any idea why? Or
even better how to force the overwite?

Thanks in advance

Peter
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Save As behaviour

Private Sub cbEnd_Click()

Dim fname As String

Application.DisplayAlerts = False
fname = "Last end status"
ActiveWorkbook.SaveAs Filename:=fname,
ConflictResolution:=xlLocalSessionChanges
Application.DisplayAlerts = True
Unload Me

End Sub

or
Private Sub cbEnd_Click()

Dim fname As String

fname = "Last end status"
On Error Resume Next
Kill fName & ".xls"
On Error goto 0
ActiveWorkbook.SaveAs Filename:=fname,
ConflictResolution:=xlLocalSessionChanges
Unload Me

End Sub

--
Regards,
Tom Ogilvy

"Peter" wrote in message
...
Hope someone can help, as is usually the case I'm probably missing
something really obvious!

I have a button on a form that I want to save the last contents of the
current workbook to a specific name as follows...

Private Sub cbEnd_Click()

Dim fname As String

fname = "Last end status"
ActiveWorkbook.SaveAs Filename:=fname,
ConflictResolution:=xlLocalSessionChanges
Unload Me

End Sub

I have another subroutine, part of which does exactly the same thing but
at specific periods as data changes...

fname = "Status at" + Str(vaNextClock) + " secs"

vaCurrClock = vaCurrClock Mod 5
vaNextClock = vaNextClock Mod 5

If vaCurrClock < vaNextClock And vaNextClock = 0 Then
ActiveWorkbook.SaveAs Filename:=fname,
ConflictResolution:=xlLocalSessionChanges
End If

My issue is that the second piece of code works fine but the first piece
always shows the confirm dialog box, does anyone have any idea why? Or
even better how to force the overwite?

Thanks in advance

Peter



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Save As behaviour

Tom Ogilvy wrote:
Private Sub cbEnd_Click()

Dim fname As String

Application.DisplayAlerts = False
fname = "Last end status"
ActiveWorkbook.SaveAs Filename:=fname,
ConflictResolution:=xlLocalSessionChanges
Application.DisplayAlerts = True
Unload Me

End Sub


Thanks Tom, that's a bit more elegant than my workaround using KILL. Any idea why the second worked with no issues or is it an "undocumented feature"?

Peter
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Save As behaviour

Probably because you don't have any existing workbooks that have exactly
that name. If you eventually have such duplicate named books, you will
probably have the problem.

--
Regards,
Tom Ogilvy

"Peter" wrote in message
...
Tom Ogilvy wrote:
Private Sub cbEnd_Click()

Dim fname As String

Application.DisplayAlerts = False
fname = "Last end status"
ActiveWorkbook.SaveAs Filename:=fname,
ConflictResolution:=xlLocalSessionChanges
Application.DisplayAlerts = True
Unload Me

End Sub


Thanks Tom, that's a bit more elegant than my workaround using KILL. Any

idea why the second worked with no issues or is it an "undocumented
feature"?

Peter



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
Range-name Behaviour Peter Excel Discussion (Misc queries) 3 September 16th 08 10:06 PM
Strange if(***) behaviour? Excel 2003 - SPB Excel Discussion (Misc queries) 6 August 6th 06 05:34 PM
Strange behaviour Edgar Thoemmes Excel Worksheet Functions 1 February 8th 05 03:20 PM
Behaviour of Save as and Displayalerts Hari[_3_] Excel Programming 3 June 10th 04 10:23 PM
Key behaviour Rodney[_2_] Excel Programming 1 July 18th 03 11:07 AM


All times are GMT +1. The time now is 04:42 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"