Open a pdf and print in pdf

nianchi111

Board Regular
Joined
Aug 24, 2007
Messages
197
Office Version
  1. 365
Hi All,

I have multiple pdf files in the folder C:\user\desktop\test

I need to open each file and print it using "Microsoft print to pdf" and save it with the same name in the folder C:\user\desktop\test\output

Please help me !!!

Thanks
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
I'm using the pdf file to convert to excel, but with the current file I'm unable to convert as the result is in

Not exactly as per the pdf, if I print it again as pdf and I'm getting the result as per the pdf.
%PDF-1.4 %âãÏÓ 3 0 obj [/PDF/Text/ImageB/ImageC/ImageI] endobj 5 0 obj [611 556 278 556 333 278 722 556 222 222 500 278 611 667 500 333 667 722 667 667 722 778 722 333 722 556 333 278 556 556 556 833 667 667 667 278 667 778 722 556 556 556 278 556 556 556 556 556 556 556 833 556 556 778 278 667 556 722 778 667 278 556 500 500 278 722 556] endobj 7 0 obj [-665 -325 2000 1040] endobj 8 0 obj <>stream xœ¤} |TÅýø̼s÷íñöÈÞÙ}É&›%

Code used to convert pdf to excel

Public Sub test()

Dim InitialFolder As String, FullName As Variant, ShtPdfData As Worksheet
Dim wdApp As Object, wdPdfDoc As Object, wdRange As Object

InitialFolder = Environ("userprofile") & "\Desktop\test\"
ChDrive Left(InitialFolder, 1)
ChDir InitialFolder
FullName = Application.GetOpenFilename("PDF Files (*.pdf), *.pdf", 1)

If Not VarType(FullName) = vbBoolean Then

Set wdApp = CreateObject("Word.Application")
wdApp.Visible = True

Set wdPdfDoc = wdApp.Documents.Open(filename:=FullName, ConfirmConversions:=False, ReadOnly:=False, Format:=0, NoEncodingDialog:=True)
Set wdRange = wdPdfDoc.Range(1)
wdRange.WholeStory
wdRange.Copy

Set ShtPdfData = ThisWorkbook.Worksheets.Add
ShtPdfData.PasteSpecial Format:="HTML", Link:=False, DisplayAsIcon:=False, NoHTMLFormatting:=True
Application.Goto ShtPdfData.Range("A1")

wdPdfDoc.Close False
wdApp.DisplayAlerts = False
wdApp.Quit

Else
'cancel was pressed
End If
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,695
Messages
6,126,261
Members
449,307
Latest member
Andile

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top