ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Saveing a file (Confirm Replace) (https://www.excelbanter.com/excel-programming/289130-saveing-file-confirm-replace.html)

rudolpsh[_5_]

Saveing a file (Confirm Replace)
 
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:


---
Message posted from http://www.ExcelForum.com/


Bob Phillips[_6_]

Saveing a file (Confirm Replace)
 
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)

"rudolpsh " wrote in message
...
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:


---
Message posted from http://www.ExcelForum.com/




rudolpsh[_6_]

Saveing a file (Confirm Replace)
 
1000 - thank you's...


---
Message posted from http://www.ExcelForum.com/


tolgag[_18_]

Saving a file (Confirm Replace)
 
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


---
Message posted from http://www.ExcelForum.com/


rudolpsh[_7_]

Saving a file (Confirm Replace)
 
thank

--
Message posted from http://www.ExcelForum.com



All times are GMT +1. The time now is 02:16 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com