Confirm save file

E

ernie

Hello to you all happy new year.

In my code below i dont get the security alert which tells me that i'm gonna
overwrite an existing file name. Can someone help me modify this code to
display the security alert.

Sub PrintToFile()
'This example publish the first two pages of the ActiveSheet
'You can change the from and To to only publish the pages you want
Dim FilenameStr As String

If Dir(Environ("commonprogramfiles") & "\Microsoft Shared\OFFICE" _
& Format(Val(Application.Version), "00") & "\EXP_PDF.DLL") <> "" Then

FilenameStr =
Application.GetSaveAsFilename(FileFilter:="DecProFile(*.pdf), *.pdf",
InitialFileName:=Trim(Workbooks("Declaration
Pro.xls").Worksheets("Front").Range("B4").Value))
ActiveSheet.ExportAsFixedFormat _
Type:=xlTypePDF, _
Filename:=FilenameStr, _
Quality:=xlQualityStandard, _
IncludeDocProperties:=True, _
IgnorePrintAreas:=False, _
From:=1, _
To:=Worksheets("front").Range("G6").Value, _
OpenAfterPublish:=False
MsgBox "You can find the PDF file here : " & FilenameStr
Else
MsgBox "PDF add-in Not Installed, Contact (e-mail address removed)/2257778
for installation file"
End If
End Sub

Thanks in Advance
 
J

JLGWhiz

Is it actually overwriting or is it putting the same file name with a
different file extension. If it is the latter, Excel sees the different file
extension as a completely different file and will not execute the error
message. If it is overwriting without issuing the warning, then there is a
problem somewhere.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top