Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 67
Default SaveAs doesn't work

Excel Guru, please help!

I try to create a code when user save the workbook, the file name will
be taken from cell C10 & C7. It works fine with save button, but if I
select File-Save as, the code will run twice, if I disable the
enableevents it will disactivate another code in other sheets. Thanks

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

filesavename = Application.GetSaveAsFilename(Sheet1.Range("C10") &
Sheet1.Range("C7"), fileFilter:="Microsoft Excel Workbook (*.xls),
*.xls")

If filesavename < False Then

Else
Cancel = True
End If
end sub

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default SaveAs doesn't work

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

filesavename = Application.GetSaveAsFilename( _
Sheet1.Range("C10") & Sheet1.Range("C7"), _
fileFilter:="Microsoft Excel Workbook (*.xls),*.xls")

If filesavename < False Then
Application.EnableEvents = False
if lcase(thisworkbook.fullname) = lcase(filesavename) then
thisworkbook.Save
else
on Error resume Next
kill filesavename
on Error goto 0
thisworkbook.SaveAs filesavename
end if
End If
Application.EnableEvents = True
Cancel = True
end sub

--
Regards,
Tom Ogilvy

"broogle" wrote in message
ups.com...
Excel Guru, please help!

I try to create a code when user save the workbook, the file name will
be taken from cell C10 & C7. It works fine with save button, but if I
select File-Save as, the code will run twice, if I disable the
enableevents it will disactivate another code in other sheets. Thanks

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

filesavename = Application.GetSaveAsFilename(Sheet1.Range("C10") &
Sheet1.Range("C7"), fileFilter:="Microsoft Excel Workbook (*.xls),
*.xls")

If filesavename < False Then

Else
Cancel = True
End If
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
More help with SaveAs Glen Mettler[_2_] Excel Programming 2 February 14th 04 02:50 AM
Help with SaveAs Glen Mettler[_2_] Excel Programming 1 February 14th 04 02:48 AM
Help with saveas Glen Mettler[_2_] Excel Programming 2 February 12th 04 11:00 PM
Help with SaveAs Glen Mettler[_2_] Excel Programming 1 January 29th 04 05:32 PM
SaveAs didn't work in VB protected mode manfred Excel Programming 0 November 26th 03 08:03 AM


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