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

Hi

I have a read-only file and I want to display the SaveAs dialog box and
suggest a filename which is a date on the worksheet, when either Save or
SaveAs is clicked.

I had a problem with the SaveAs dialog box being displayed twice as it was
readonly file but I think I've cured that. The problem now is that the
Workbook is saved with the suggested filename even if the user trys to change
it to something else.

Here is my code

Public SAflag as boolean 'true if BeforeSave run

Private Sub Workbook_Open
SAflag = False
end sub

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel as Boolean)
dim fName
if IsDate(Sheet1.range("b3").value)=true then
fName = format(Datevalue(Sheet1.range("b3").value), "dd-mm-yyyy")
end if
if SAflag = false then
if SaveAsUI = true then
Cancel = True
Application.GetSaveAsFilename(fName)
if fName<False then
SAflag = True
Thisworkbook.SaveAs(fName)
end if
end if
end if
end if
end sub



Thanks Guys

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default GetSaveasFileName

Maybe just stopping the .saveas from calling the _beforesave would work:

If fName < False Then
SAflag = True
Application.EnableEvents = False
ThisWorkbook.SaveAs fName
Application.EnableEvents = True
End If

If it doesn't you may want to paste directly from your code--I think you had a
typo in your post.

Libby wrote:

Hi

I have a read-only file and I want to display the SaveAs dialog box and
suggest a filename which is a date on the worksheet, when either Save or
SaveAs is clicked.

I had a problem with the SaveAs dialog box being displayed twice as it was
readonly file but I think I've cured that. The problem now is that the
Workbook is saved with the suggested filename even if the user trys to change
it to something else.

Here is my code

Public SAflag as boolean 'true if BeforeSave run

Private Sub Workbook_Open
SAflag = False
end sub

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel as Boolean)
dim fName
if IsDate(Sheet1.range("b3").value)=true then
fName = format(Datevalue(Sheet1.range("b3").value), "dd-mm-yyyy")
end if
if SAflag = false then
if SaveAsUI = true then
Cancel = True
Application.GetSaveAsFilename(fName)
if fName<False then
SAflag = True
Thisworkbook.SaveAs(fName)
end if
end if
end if
end if
end sub

Thanks Guys


--

Dave Peterson
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
Help with getsaveasfilename Jo Excel Discussion (Misc queries) 2 June 5th 07 12:41 AM
GetSaveAsFilename - Save as box Der Excel Programming 5 August 31st 04 03:00 PM
GetSaveAsFileName Greg Hadrych Excel Programming 1 July 29th 04 12:52 AM
After GetSaveAsFileName question Stuart[_5_] Excel Programming 1 July 9th 04 09:29 PM
GetSaveAsFilename Anand Attavane Excel Programming 2 October 22nd 03 01:21 AM


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