Save XL file but don't want XL to prompt user 
Author Message
 Save XL file but don't want XL to prompt user

I don't want the user to have an option to override the existing file or
not. The code must override the file should it exist.

This is the code I am using:

ActiveWorkbook.SaveAs Filename:= _
        "C:\Documents\Test.xls", FileFormat:=xlSaveChanges _
        , Password:="", WriteResPassword:="", ReadOnlyRecommended:=False, _
        CreateBackup:=False

Your help will be appreciated.

Nico Le Roux



Mon, 01 Aug 2005 22:59:21 GMT  
 Save XL file but don't want XL to prompt user
Hi Nico,

Eventhough this is a Word (!!) dedicated newsgroup,
here's the trick in Excel:

First test whether file was saved before (so an existing file)
Path property is empty
Next, equal Cancel (bail out) to SaveAsUI when user
chooses to SaveAs ...

In ThisWorkbook module go

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

If ActiveWorkbook.Path <> "" then Cancel = SaveAsUI
End Sub

Krgrds,
Perry



Quote:
> I don't want the user to have an option to override the existing file or
> not. The code must override the file should it exist.

> This is the code I am using:

> ActiveWorkbook.SaveAs Filename:= _
>         "C:\Documents\Test.xls", FileFormat:=xlSaveChanges _
>         , Password:="", WriteResPassword:="", ReadOnlyRecommended:=False,
_
>         CreateBackup:=False

> Your help will be appreciated.

> Nico Le Roux



Tue, 02 Aug 2005 06:10:50 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. SQL; Select Into Xl-File From XL-File

2. Read XL-sheet with VB4 without XL

3. Read XL-sheet with VB4 without XL

4. Read XL-sheet with VB4 without XL

5. H2 insert new XL worksheet incl data into existing XL workbook

6. Saving an XL File as a .txt file

7. Saving XL Document to outlook folder

8. Trying to hook the Word/XL/PowerPoint Save routines

9. HELP: can't copy XL worksheets from Access via VBA

10. Setting CurDir Based on How XL FIle was Launched

11. Reading CSV Files in XL-VBA

12. how do I check XL file version programatically?

 

 
Powered by phpBB® Forum Software