#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default VBA and PDF

I can't the following to work - says FileList not recognized?
'Copy all PDF files in source path into an array
arrPDFFileList = FileList(argPDFSourcePath, "*.pdf", False)
If IsEmpty(arrPDFFileList) Then MsgBox "No PDF files were found!",
vbCritical, "FILES NOT FOUND!": Call CommonEnd(True)


Public Function PDFCombineFiles(argPDFSourcePath As String,
argDestinationPath As String, argDestinationFileName As String)
'FUNCTION COMBINES ALL PDF FILES IN THE SOURCE PATH INTO A SINGLE PDF
DOCUMENT;
Dim arrPDFFileList() As Variant
Dim strFullPath As String
Dim intX As Integer
Dim intLastPage As Integer
Dim intNumPagesToInsert As Integer

'Copy all PDF files in source path into an array
arrPDFFileList = FileList(argPDFSourcePath, "*.pdf", False)
If IsEmpty(arrPDFFileList) Then MsgBox "No PDF files were found!",
vbCritical, "FILES NOT FOUND!": Call CommonEnd(True)




'Dimension required objects
Dim objAcroExchApp As Object
Dim objAcroExchPDDoc As Object
Dim objAcroExchInsertPDDoc As Object


'Establish object references
Set objAcroExchApp = CreateObject("AcroExch.App")
Set objAcroExchPDDoc = CreateObject("AcroExch.PDDoc")


'Optionally show the Acrobat Exchange window - just to see if it works
'oAcroExchApp.Show


'Open the first file in the list
strFullPath = argPDFSourcePath & arrPDFFileList(1)
objAcroExchPDDoc.Open strFullPath


'Initialize a loop through each file in the PDF folder
For intX = 1 To UBound(arrPDFFileList)


'Concatenate source path and file name into a single string
strFullPath = argPDFSourcePath & arrPDFFileList(intX)


'If intX 0 Then
If intX 1 Then


'Sequentially open each remaining file in the directory
objAcroExchPDDoc.Open strFullPath


'Get the total pages less one for the last page num [zero
based]
intLastPage = objAcroExchPDDoc.GetNumPages - 1


'Obtain an object reference to the Exchange program in PDF
Set objAcroExchInsertPDDoc = CreateObject("AcroExch.PDDoc")


'Open the file to insert
objAcroExchInsertPDDoc.Open strFullPath


'Count the pages in the current document to insert
intNumPagesToInsert = objAcroExchInsertPDDoc.GetNumPages


'Insert the pages
objAcroExchPDDoc.InsertPages intLastPage,
objAcroExchInsertPDDoc, 0, intNumPagesToInsert, True


'Close the document
objAcroExchInsertPDDoc.Close
End If
Next intX


'Save the entire document using SaveFull [0x0001 = &H1]
objAcroExchPDDoc.Save &H1, argDestinationPath & argDestinationFileName


'Close the PDDoc
objAcroExchPDDoc.Close


'Close Acrobat Exchange
objAcroExchApp.Exit


'Toss objects and release memory
Set objAcroExchApp = Nothing
Set objAcroExchPDDoc = Nothing
Set objAcroExchInsertPDDoc = Nothing


End Function

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default VBA and PDF

It looks like FileList is a function that returns an array of file names.
As you have not included it, that's just a guess.
But I suspect you are missing it, so you will need to replicate whatever it
was designed to do.

NickHK

wrote in message
oups.com...
I can't the following to work - says FileList not recognized?
'Copy all PDF files in source path into an array
arrPDFFileList = FileList(argPDFSourcePath, "*.pdf", False)
If IsEmpty(arrPDFFileList) Then MsgBox "No PDF files were found!",
vbCritical, "FILES NOT FOUND!": Call CommonEnd(True)


Public Function PDFCombineFiles(argPDFSourcePath As String,
argDestinationPath As String, argDestinationFileName As String)
'FUNCTION COMBINES ALL PDF FILES IN THE SOURCE PATH INTO A SINGLE PDF
DOCUMENT;
Dim arrPDFFileList() As Variant
Dim strFullPath As String
Dim intX As Integer
Dim intLastPage As Integer
Dim intNumPagesToInsert As Integer

'Copy all PDF files in source path into an array
arrPDFFileList = FileList(argPDFSourcePath, "*.pdf", False)
If IsEmpty(arrPDFFileList) Then MsgBox "No PDF files were found!",
vbCritical, "FILES NOT FOUND!": Call CommonEnd(True)




'Dimension required objects
Dim objAcroExchApp As Object
Dim objAcroExchPDDoc As Object
Dim objAcroExchInsertPDDoc As Object


'Establish object references
Set objAcroExchApp = CreateObject("AcroExch.App")
Set objAcroExchPDDoc = CreateObject("AcroExch.PDDoc")


'Optionally show the Acrobat Exchange window - just to see if it works
'oAcroExchApp.Show


'Open the first file in the list
strFullPath = argPDFSourcePath & arrPDFFileList(1)
objAcroExchPDDoc.Open strFullPath


'Initialize a loop through each file in the PDF folder
For intX = 1 To UBound(arrPDFFileList)


'Concatenate source path and file name into a single string
strFullPath = argPDFSourcePath & arrPDFFileList(intX)


'If intX 0 Then
If intX 1 Then


'Sequentially open each remaining file in the directory
objAcroExchPDDoc.Open strFullPath


'Get the total pages less one for the last page num [zero
based]
intLastPage = objAcroExchPDDoc.GetNumPages - 1


'Obtain an object reference to the Exchange program in PDF
Set objAcroExchInsertPDDoc = CreateObject("AcroExch.PDDoc")


'Open the file to insert
objAcroExchInsertPDDoc.Open strFullPath


'Count the pages in the current document to insert
intNumPagesToInsert = objAcroExchInsertPDDoc.GetNumPages


'Insert the pages
objAcroExchPDDoc.InsertPages intLastPage,
objAcroExchInsertPDDoc, 0, intNumPagesToInsert, True


'Close the document
objAcroExchInsertPDDoc.Close
End If
Next intX


'Save the entire document using SaveFull [0x0001 = &H1]
objAcroExchPDDoc.Save &H1, argDestinationPath & argDestinationFileName


'Close the PDDoc
objAcroExchPDDoc.Close


'Close Acrobat Exchange
objAcroExchApp.Exit


'Toss objects and release memory
Set objAcroExchApp = Nothing
Set objAcroExchPDDoc = Nothing
Set objAcroExchInsertPDDoc = Nothing


End Function



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 03:46 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"