View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
mooresk257 mooresk257 is offline
external usenet poster
 
Posts: 50
Default Save as crashes Excel - sometimes

I have this code in the ThisWorkbook object:

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)

Dim Fname As Variant

Fname = Sheet1.Range("F3").Value & "-" & Sheet1.Range("F4").Value
Application.Dialogs(xlDialogSaveAs).Show Fname

End Sub

Where F3 & F4 are text values, i.e. the cells are formatted as text. The
cells contain a serial number and machine name, and so the file name is
concatenated as "0000-Machine Name.xls"

Sometimes on the file save event Excel (v2003) crashes. Most of the time it
doesn't. The code works like it is supposed to - but is there something
missing, or some error trapping I can add to prevent the crash?

Thanks!