Re: Workbook_BeforeSave()
From: bmm (newsgroup.com)
Date: 08/16/04
- Next message: bl: "Re: Run-time error '91'"
- Previous message: Katherine: "Subtracting dates to come up with number of days"
- In reply to: Tom Ogilvy: "Re: Workbook_BeforeSave()"
- Next in thread: Tom Ogilvy: "Re: Workbook_BeforeSave()"
- Reply: Tom Ogilvy: "Re: Workbook_BeforeSave()"
- Messages sorted by: [ date ] [ thread ]
Date: Mon, 16 Aug 2004 19:07:03 +0530
Thanks Tom,
this code works but when i try to save the file with the the existing file
name,
it asks if i want to replace the existing file, if i say No/ Cancel then it
gives me an Run time error "1004"
which says
"Method SaveAs of object '_Workbook' failed "
Can you please explain me why is it so?
Thanks once again
"Tom Ogilvy" <twogilvy@msn.com> wrote in message
news:OR9NDG5gEHA.1344@TK2MSFTNGP11.phx.gbl...
> Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, -
> Cancel As Boolean)
> Application.EnableEvents = False
> filesavename = Application.GetSaveAsFilename( _
> fileFilter:="Microsoft Excle Files Files (*.xls), *.xls")
> If filesavename <> False Then
> Thisworkbook.SaveAs FileName:=filesavename
> End If
> Application.EnableEvents = True
> Cancel = True
> End Sub
>
> --
> Regards,
> Tom Ogilvy
>
>
> "bmm" <newsgroup.com> wrote in message
> news:uNlvuz4gEHA.216@tk2msftngp13.phx.gbl...
> > Hi,
> > How can I trap the file save as /save event and get the filename entered
> in
> > the dialogbox?
> > I tried to get the file name in "Workbook_BeforeSave() " event, but it
> > displays the dialog twice FileSave As dialog twice.
> > How can i avoid that dialog appearing twice
> >
> > Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
> > Boolean)
> > Application.EnableEvents = False
> > filesavename = Application.GetSaveAsFilename( _
> > fileFilter:="Microsoft Excle Files Files (*.xls), *.xls")
> > If filesavename <> False Then
> > filesavename = filesavename
> > End If
> > Application.EnableEvents = True
> > Cancel = True
> > MsgBox filesavename
> > End Sub
> >
> >
> >
> >
>
>
- Next message: bl: "Re: Run-time error '91'"
- Previous message: Katherine: "Subtracting dates to come up with number of days"
- In reply to: Tom Ogilvy: "Re: Workbook_BeforeSave()"
- Next in thread: Tom Ogilvy: "Re: Workbook_BeforeSave()"
- Reply: Tom Ogilvy: "Re: Workbook_BeforeSave()"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|