I'm in a little over my head here and was hoping I could get some help. I've created a macro that will go down column in Excel, find the folder it is in, and combine three pdfs whos names are in the current excel file. This part works perfectly fine, but I want to finish this off by converting the pdf to grayscale to remove the color in one of the files. Here is my code:
Sub Reports()
Dim AcroApp As Acrobat.CAcroApp
Dim Part1Document As Acrobat.CAcroPDDoc
Dim Part2Document As Acrobat.CAcroPDDoc
Dim Part3Document As Acrobat.CAcroPDDoc
Dim dsheet As Worksheet
Dim numPages As Integer
Dim directoryf As String
Dim i As Integer
i = 7
Set dsheet = ActiveWorkbook.Sheets(1)
Set AcroApp = CreateObject("AcroExch.App")
Set Part1Document = CreateObject("AcroExch.PDDoc")
Set Part2Document = CreateObject("AcroExch.PDDoc")
Set Part3Document = CreateObject("AcroExch.PDDoc")
Do While dsheet.Cells(i, 1) <> ""
directoryf = "S:\Month End Reports\2013\Fiscal Period end 05-20-2013\"
directoryf = directoryf & Dir(directoryf & dsheet.Cells(i, 1) & "*", vbDirectory) & "\"
Part1Document.Open (directoryf & Dir(directoryf & dsheet.Cells(2, 1) & "*.pdf"))
Part2Document.Open (directoryf & Dir(directoryf & dsheet.Cells(3, 1) & "*.pdf"))
Part3Document.Open (directoryf & Dir(directoryf & dsheet.Cells(4, 1) & "*.pdf"))
' Insert the pages of Part2 after the end of Part1
numPages = Part1Document.GetNumPages()
If Part1Document.InsertPages(numPages - 1, Part2Document, 0, Part2Document.GetNumPages(), True) = False Then
MsgBox "Cannot insert pages for " & dsheet.Cells(i, 1)
End If
numPages = Part1Document.GetNumPages()
If Part1Document.InsertPages(numPages - 1, Part3Document, 0, Part3Document.GetNumPages(), True) = False Then
MsgBox "Cannot insert pages for " & dsheet.Cells(i, 1)
End If
If Part1Document.Save(PDSaveFull, "H:\test\" & dsheet.Cells(i, 1) & " Yardi.pdf") = False Then
MsgBox "Cannot save the modified document for " & dsheet.Cells(i, 1)
End If
Part1Document.Close
Part2Document.Close
Part3Document.Close
i = i + 1
Loop
AcroApp.Exit
Set AcroApp = Nothing
Set Part1Document = Nothing
Set Part2Document = Nothing
Set Part3Document = Nothing
End Sub
This all works fine, but I want there to be no color in the final product as well. I've combed through the Acrobat API, and haven't found anything. Any help would be greatly appreciated.
Bookmarks