Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Save active tab to PDF

Status
Not open for further replies.

travisj

Technical User
May 14, 2002
5
0
0
US
I have a report that has several tabs. What would be the vba code to export/save the active tab as a pdf.

Thanks in advance.
 
Hi,

Below is the code to export the active report as PDF.

Code:
Sub ExportPDF()
    ThisDocument.ActiveReport.ExportAsPDF ("C:\Test")
End Sub

Sri
 
Thank you this work just like I wanted. I did make it so it saved the report name as well.

Sub ExportPDF()
Dim reportname
Dim str

reportname = ThisDocument.ActiveReport.Name
str = "C:\test\" & reportname

ThisDocument.ActiveReport.ExportAsPDF (str)
End Sub

The only problem I have is that the folder that the file is going to be saved must already exist. Do you now how to check to see if the directory exist and if not create the directory?
 
Hi,

Code to find out whether a Directory exists or not.

Code:
Sub CheckFolder()
    Dim FileObject As FileSystemObject
    Dim Folder As Folder
    Dim FolderName As String
    
    Set FileObject = CreateObject("Scripting.FileSystemObject")
    
    FolderName = InputBox("Enter Folder Path")
    If FileObject.FolderExists(FolderName) = True Then
        MsgBox "Folder Exists"
    Else
        MsgBox "Folder Doesn't Exists"
        FileObject.CreateFolder (FolderName)
    End If
End Sub

Make sure you include Microsoft Scripting Runtime. Tools->References->Microsoft Scripting Runtime.

Regards,
Sri
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top