Free Microsoft Excel 2013 Quick Reference

VBA: merge pdf files

Is it possible to merge pdf files using vba in excel? I have a list in excel, defining which files need to be combined.

I have the following:
- a list with files
1.pdf
2.pdf
3.pdf
4.pdf
5.pdf
6.pdf
7.pdf
8.pdf
- I have an excel file with the following sheet:
File list,first pdf;last pdf
merge1.pdf;1.pdf;3.pdf
merge2.pdf;4.pdf
merge3.pdf;5.pdf;8.pdf

In other words, sometimes a file has to be renamed (given in the case for merge2.pdf), sometimes I need to combine multiple pdf's.
In the case of merge1.pdf I need to combine 1.pdf, 2.pdf and 3.pdf.
For merge3.pdf I need to combine 5.pdf, 6.pdf, 7.pdf and 8.pdf

Any ideas?


Hi,

I need to do the following:
- Select a large pdf file, which need to be cut into different sections
- Merge/print specific pages of the PDF file based on the information found in a row
- Rename newly merged files

It needs to be working for both mac as win. Using an Adobe Reader is fine, or any other free/open source cross-platform pdf printer.

Example of excel file:
Title of merged pdf file Start page in original large pdf End page in original large pdf Title1.pdf 5 6 Title2.pdf 7 12 Title3.pdf 14 21
I should end up with a folder holding title1.pdf, title2.pdf and title3.pdf

Is this possible?

I have some embedded PDF files in Excel file. I want to save them in a separate folder as seperate files, by pressing a button in toolbar.
How to do that using VBA?

Thanks

Esteemed VBA Geeks!

I am looking to open a known PDF file, (i.e. – I know what name the PDF file is), from VBA. The problem is – that – I do not know where the Adobe Reader program will reside on the customer computer.

My wrong guess was to:

[mc] Shell "C:Bob.pdf"

But within VBA that does not work.

What does work is:

[mc] t = "C:Program FilesAdobeReader
[mc] 8.0ReaderAcroRd32.exe"
[mc] Shell """" + t + """" + "C:Bob.pdf"

Except for my computer, I will not know where the Adobe Reader is on
the customer computer that will be running the application code!

From a command prompt:

[mc] C:Bob.pdf

Does open the designated PDF file, (Bob) – I am looking for a command in VBA that does the same thing.

As always – your help is greatly appreciated!

Thank You

Choppork

0940 CST
1/11/2008

Hi All,

I am looking for code in excel vba that will open a pdf file and save a copy of it in a different location and return to excel o repeat this process. "FollowHyperlink" method works only to open the pdf, but how do I make it to save in a different location. I do not have pdf writer so "AcroExch.App" object does not work either.

I would appreciate if someone can really help me here.

Thanks,

Peace

OK...
I am trying to perform a very time saving mail merge operation for my company. Unfortunately I am hitting a wall here because I can't seem to find a command that would retrieve a specific pdf file for each email message (i.e. each email we send needs to include a pdf attachment unique to the recipient). I can't find any way to do this. I think MS doesn't allow this, so if there is a work-around, that would be excellent.

I have found a way to attach 1 document to all of the messages, but that's not going to help us.

We have the name for each PDF, which we could easily place in excel and use for the mail merge if a code or a command of some sort exists. Thanks for your help.

Hello All,

Please, does anyone know a simple code to print a specific page of a pdf file using Excel VBA.

I have a spreadsheet that contains the pdf file name, the page i would like to print and quantities of that page.

Please help.

Many thanks
Charlie

I wish to open a pdf file using vba. Does anyone know whether this can be done?

I have an Excel 2003 file containing a sheet for requesting reimbursement of travel expenses available on the office network. Employees can open, edit, print, and save to their directory on their desk top or laptop. When the user prints, a VBA routine sorts the records and checks for missing information (cells colored red by conditional formatting).

If information is missing, the print process is cancelled and a message box tells the user to fill in the information.

If all is OK, the form prints.

I have a PDF file of 100 pictures from the company holiday party. I want Excel to display a picture from the PDF file for about two seconds just before the print process is completed. Ideally, Excel would automatically increment to the next picture each time the print process is run. After the last photo is shown, return to the first.

I am somewhat new to VBA so please be gentle (and explicit). If this works, it will impress my coworkers and lead them to think I know what I am doing.

Thanks so much.

Using 2003

Below is the macro I recorded opening an Adobe.pdf file which is embedded in the same worksheet.

Sub Macro1()
ActiveSheet.Shapes("Object 32").Select
Selection.Verb Verb:=xlPrimary
End Sub

When I open the file (also when the macro was recorded) Acrobat came up - all seemed OK.

But when I attempted to run the macro, I get a VBA error "cannot open application."

What am I missing?

Thanks for any thoughts

Dennis

Using 2003

Below is the macro I recorded opening an Adobe.pdf file which is embedded in the same worksheet.

Sub Macro1()
ActiveSheet.Shapes("Object 32").Select
Selection.Verb Verb:=xlPrimary
End Sub

When I open the file (also when the macro was recorded) Acrobat came up - all seemed OK.

But when I attempted to run the macro, I get a VBA error "cannot open application."

What am I missing?

Thanks for any thoughts

Dennis

I manage a number of .pdf files that I sort and create a uniqe combined
(combined into one .pdf) bundle for each client. I know I can
associate .pdfs in Excel as hyperlinks and query then and sort based on
client requirements.

Does anyone have any ideas on how to automatically print a select set
of .pdf documents, combining them into one .pdf document using VBA
code?

Thank you,

Hi,

I am looking for a macro to merge two different pdf files which are available in C drive.

Files below in C drive:

"c" drive coverpage.pdf
"C" drive 1.pdf
"C" drive 2.pdf
"C" drive 3.pdf

I want the macro to merge the coverpage from C drive with each pdf files that are named as 1, 2, 3.

Please help....You may have to create sample pdf in your c drive to test it. If not I will send the pdf attachments...

Regards,
Vijay

I can't help but notice that there are a number of questions about this topic
but very few answers. What I need to know is this: is it possible to create
a PDF file for each print area on each worksheet in a workbook solely through
using VBA and without resorting to add-ins.

I work in an environment that is very secure and the use of individual
add-ins to resolve problems is discouraged. I need to know if there is VBA
code that will let me convert an existing print area on a worksheet into a
PDF file and use the sheetname as the name of the PDF file.

Thanks in advance for any help on this.

George

I'm trying to print a given Acrobat Reader PDF file from VBA. (Office 2000 &
Acrobat Reader 6)
I've included the reference to the Adobe Acrobat Control for ActiveX
(pdf.ocx),
but I'm unable to actually create an instance of the PDF control.
I've also tried putting a Microsoft Webbrowser control an my Excel
worksheet, and calling the
Webbrowser1.Navigate "someserversomefoldersomefile.pdf" method.
The webbrowser control indeed shows the PDF file, but I did not find a way
to print it's contents from VBA.

I'm looking for someone who can put me on the right track for this seemingly
simple problem.

Matthias Claes
matthias.claes(-at-)stadsbader.com

Dear Friends,

I have PDF file name with path address mentioned in the C3:C1500 of sheet1
(Eg:- C:PDFfileOct-11.pdf). Could any one give a vba code to print all these PDF file together.

Thanks
Abdul Jaleel
Dubai

Folks,

I have an excel worksheet with two columns “A” and “B”. Column “A” containing current file names of the pdf files which I already saved in the folder "C:UserskrjoshiDocumentsrename”, Column “B” containing new file name which I need to rename it. What I am looking for I want to rename the all pdf files with “B” Column names by using VBA.

Thanks in advance.

Joshi

Folks,

I have an excel worksheet
with two columns “A” and “B”. Column “A” containing current file names of the
pdf files which I already saved in the folder
"C:UserskrjoshiDocumentsrename”.
Column “B” containing new file name which
I need to rename it. What I am looking for I want to rename the all pdf files
with “B” Column names by using VBA.

Thanks in advance.

Joshi

Hello,

This is my first post so please be patient....

I have created a macro that saves a worksheet as pdf, lets the user select location for saving the file, lets the user choose whether to open the file and folder where its located.

My issue is that i cant work out how to get the macro to open the resulting pdf file. i get an error "cannot open specified file"

Everything else works fine...

I have used a lot of help from this forum...

Please help...

excel 2010, windows 7


	VB:
	
 Make_PDF() 
     ' Create and save .pdf
     '*****USE THIS VERSION OF THE MACRO******'
    Dim myval As Variant, strPath As String, pdfName As String, FullName As String, username As String, strDirname As String,
strPathname As String, strDefpath As String 
    On Error Goto Errorcatch 
    pdfName = Range("A1").Text 
    username = Range("A3").Text 
    FullName = strPath & "" & pdfName & ".pdf" 
    Call BrowseForFolder(dhcCSIdlDesktop, dhcBifReturnOnlyFileSystemDirs, _ 
    strPath, pszTitle:="Select a folder:") 
    ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:=pdfName _ 
    , Quality:=xlQualityMedium, IncludeDocProperties:=False, _ 
    IgnorePrintAreas:=False 
    YesNo = MsgBox("Would you like to see the report now?", vbYesNo + vbQuestion, "Open Report?") 
    Select Case YesNo 
    Case vbYes 
        ThisWorkbook.FollowHyperlink pdfName & ".pdf" 
    Case vbNo 
    End Select 
    YesNo = MsgBox("Would you like to open the folder where the report was saved?" _ 
    , vbYesNo + vbQuestion, "Open Folder?") 
    Select Case YesNo 
    Case vbYes 
        ActiveWorkbook.FollowHyperlink Address:=strPath, NewWindow:=False 
    Case vbNo 
    End Select 
    Exit Sub 
Errorcatch: 
    MsgBox Err.Description 
End Sub 

If you like these VB formatting tags please consider sponsoring the author in support of injured Royal Marines


How do I embed a pdf file into a worksheet.

I've got the following code so far:

	VB:
	
).Activate 

If you like these VB formatting tags please consider sponsoring the author in support of injured Royal Marines
The code works but it doesn't allow me to specify the filename (i.e. C:test.pdf)

Thanks.

Hi,
I have a excel sheet and a pdf file.
I want to search values of excel file in the pdf file.
How can i do this via VBA-Excel.
How to write a program , that will search data in pdf file.

I'm trying to create a pdf made of multiple Excel sheets using a VBA macro.

This is what I would like to happen:
1. The user clicks a button which starts a macro.
2. The macro changes the default printer to a pdf printer.
3. Macro prints each specified sheet to its own individual pdf page While naming each page, but all in one single pdf file. (Basically each sheet would have its own named bookmark in the single pdf file).
4. Changes the pdf printer back to default printer.

Note:
Currently I have a macro that automatically prints all of my sheets one at a time. At the moment I have to first change my default printer to the adobe printer. Then my macro that prints each sheet will then print each individual sheet to a single pdf file. Then I have to manually combine each pdf file to a single pdf.

I am looking for a way to expedite this process with a single click if possible. I have been reading that I may need the adobe SDK in order to do this, but am unsure. If someone would be able to steer me in the right direction or offer suggestions on how to start this process I would appreciate it.

Thanks in advance,

T

I need to print from Excel/VBA program directly pdf-files.
This works with the hyperlink function, but I get the file
always in previewmode. Is there a command or other possibility to
print them directly from the acrobat reader?

Thanks for tips.

felice

Well, I must be crazy today. I want to put an Excel workbook to pdf format and print it out at the click of a button located in the book. However, when I try to record the macro to get a feel for how to control pdf with Excel, I get a pdf file but no printout and no code to veiw! Any suggestions?

AC

Hi,

I've been working on this problem on and off for a number of months now and have just about got it sussed so thought I'd share it with you as it has mostly been down to postings on this board that I've got it in the end.

Thanks especially to 'biggoan' for his post: http://www.mrexcel.com/board2/viewto...136&highlight=

Anyway, this seems to avoid the need for a class module but does need you to install the Acrobat Distiller object references in Tools...References in the VBA editor.

You also need to go into the printer properties of the your Adobe PDF 'Printer' and under Printing Preferences...Adobe PDF Settings deselect the Do not send fonts to "Adobe PDF" option. Why, who knows!

Code:
Private Sub Create_PDF()

'Created by Dom Hill with considerable asistance from Biggoan and Mr Excel

Dim tempPDFFileName As String
Dim tempPSFileName As String
Dim tempPDFRawFileName As String
Dim tempLogFileName As String

Sheets("Sales Data").Activate

tempPDFRawFileName = "C:" & Range("A1").Value

'Define the postscript and .pdf file names.

tempPSFileName = tempPDFRawFileName & ".ps"
tempPDFFileName = tempPDFRawFileName & ".pdf"
tempLogFileName = tempPDFRawFileName & ".log"

' Print the Excel range to the postscript file

ActiveSheet.PrintOut Copies:=1, preview:=False, ActivePrinter:="Adobe PDF", printtofile:=True, Collate:=True,
prtofilename:=tempPSFileName

'Create PDF File

Dim myPDFDist As New PdfDistiller
myPDFDist.FileToPDF tempPSFileName, tempPDFFileName, tempShowWindow

'Delete PS File

Kill tempPSFileName
Kill tempLogFileName

End Sub
Not sure why the macro creates a log file but if you know more about VBA then you probably would.

Hope it helps someone else as it's going to save me a heap loads of time.