austin350s10
Active Member
- Joined
- Jul 30, 2010
- Messages
- 321
I am trying to use the code below to check and see if the user is able to publish documents as a PDF. Looks like it should work but each time I run it the script keeps going to the last error handler.
When I try and publish the document manually by doing:
SaveAs >
PDF or XPS >
It works just fine. What am I doing wrong here?
When I try and publish the document manually by doing:
SaveAs >
PDF or XPS >
It works just fine. What am I doing wrong here?
Code:
On Error GoTo ErrorHandler
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
"C:\Documents and Settings\" & Application.UserName & "\Local Settings\Temp\QAM-Report.pdf", Quality:=xlQualityMinimum, _
IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:= _
False
ErrorHandler:
If Err.Number = 1004 Then
Dim oShell As Object
Dim iResponse As Integer
Set oShell = CreateObject("Wscript.Shell")
iResponse = MsgBox("Sorry it looks as though you don't have a way to save this document as a PDF so I can't email it. You probably just need to download an ""Add-in"" for Excel" & vbNewLine & vbNewLine _
& "Do you want to download the ""Add-in""?", vbYesNo, "We Gotta Problem!")
If iResponse = vbYes Then
oShell.Run ("http://download.microsoft.com/download/f/4/b/f4bfd843-a0b6-4031-aa98-0a3db7403d0f/SaveAsPDFandXPS.exe")
Exit Sub
Else
Exit Sub
End If
Else
MsgBox "There is a problem with your computer that will not allow this message to be sent. Call the Office"
Exit Sub
End If
Resume Next