I am attempting to save part of a PDF into an new document using VBA in MSAccess 2k.
I realize I can open a PDF document, delete unwanted pages and save with a new name. I've done that.
I would like to try to open an existing document, create a new document, then insert the desired pages into the newly created coument and save with a new name.
The code I am attempting follows.
It's the 'Insert' that fails.
Any ideas?
= = = = = = = = =
Private Sub Extract_Click()
Dim oPDF As CAcroPDDoc
Dim nPDF As CAcroPDDoc
Dim oPagesSrc As Long
Dim FileSrcName As String
Dim FileDestName As String
Dim SaveStartPage As Long
Dim SaveEndPage As Long
FileSrcName = Me!FileSRC
FileDestName = Me!FileDest
SaveStartPage = Me!SaveStart
SaveEndPage = Me!SaveEnd
Set oPDF = CreateObject("AcroExch.PDDoc"
Set nPDF = CreateObject("AcroExch.PDDoc"
If Not oPDF.Open(FileSrcName) Then
MsgBox "Unable to Open 1"
Exit Sub
End If
oPagesSrc = oPDF.GetNumPages
If SaveEndPage > oPagesSrc Then
MsgBox "Invalid Ending Page"
Exit Sub
End If
If SaveStartPage > SaveEndPage Then
MsgBox "Invalid Starting Page"
Exit Sub
End If
If Not nPDF.Create() Then
MsgBox "Unable to Create"
Exit Sub
End If
If Not nPDF.InsertPages(0, oPDF, SaveStartPage - 1, SaveEndPage - SaveStartPage + 1, True) Then
MsgBox "Unable to Insert"
Exit Sub
End If
If Not nPDF.Save(PDSaveFull, FileDestName) Then
MsgBox "Unable to Save"
Exit Sub
End If
Set oPDF = Nothing
Set nPDF = Nothing
MsgBox "Completed"
End Sub
= = = = = =
Thanks in advance.
I realize I can open a PDF document, delete unwanted pages and save with a new name. I've done that.
I would like to try to open an existing document, create a new document, then insert the desired pages into the newly created coument and save with a new name.
The code I am attempting follows.
It's the 'Insert' that fails.
Any ideas?
= = = = = = = = =
Private Sub Extract_Click()
Dim oPDF As CAcroPDDoc
Dim nPDF As CAcroPDDoc
Dim oPagesSrc As Long
Dim FileSrcName As String
Dim FileDestName As String
Dim SaveStartPage As Long
Dim SaveEndPage As Long
FileSrcName = Me!FileSRC
FileDestName = Me!FileDest
SaveStartPage = Me!SaveStart
SaveEndPage = Me!SaveEnd
Set oPDF = CreateObject("AcroExch.PDDoc"
Set nPDF = CreateObject("AcroExch.PDDoc"
If Not oPDF.Open(FileSrcName) Then
MsgBox "Unable to Open 1"
Exit Sub
End If
oPagesSrc = oPDF.GetNumPages
If SaveEndPage > oPagesSrc Then
MsgBox "Invalid Ending Page"
Exit Sub
End If
If SaveStartPage > SaveEndPage Then
MsgBox "Invalid Starting Page"
Exit Sub
End If
If Not nPDF.Create() Then
MsgBox "Unable to Create"
Exit Sub
End If
If Not nPDF.InsertPages(0, oPDF, SaveStartPage - 1, SaveEndPage - SaveStartPage + 1, True) Then
MsgBox "Unable to Insert"
Exit Sub
End If
If Not nPDF.Save(PDSaveFull, FileDestName) Then
MsgBox "Unable to Save"
Exit Sub
End If
Set oPDF = Nothing
Set nPDF = Nothing
MsgBox "Completed"
End Sub
= = = = = =
Thanks in advance.