Saveing a file (Confirm Replace)

  • Thread starter Thread starter rudolpsh
  • Start date Start date
R

rudolpsh

Im saving my file with the following statements:


With ActiveWorkbook.PublishObjects("Report-builder")
..HtmlType = xlHtmlStatic
..Filename = "C:\Report\Test.htm"
..Publish (False)
End With

But it overwrites a file with the same name. How do I
make it so that is checks if the user would like to overwite
or not?

Thanks

:rolleyes:
 
Rudolph,

Test it yourself

If Dir("C:\myTest\Testfile1.xls") <> "" Then
MsgBox "File exists"
Else
MsgBox "File does nor exist"
End If


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
Hi,

Insert a module and paste the following declaration to the header of
this module :

Private Declare Function PathFileExists Lib "shlwapi.dll" Alias
"PathFileExistsA" (ByVal pszPath As String) As Long

then in the code you can check, if the file exist :

if CBool(PathFileExists("C:\Report\Test.htm"))) then
do something
else
do something else
end if
 
Back
Top