VBA Is it possible to open and print a text file to pdf?

dreid1011

Well-known Member
Joined
Jun 4, 2015
Messages
3,088
Office Version
  1. 365
Platform
  1. Windows
Good morning,

I am trying to make a few processes at work a bit more efficient. One of them requires me to print a set of text files to pdf. Right now, I can do it one of two ways:

Open each file and print to pdf one at a time.

or

Change my default printer to the pdf printer and right click + print each text file one at a time.

I've been poking around, but so far I have come up empty. I can open the files as TextStream objects, but can I print them?

Thank you,
 
That's great, I'm glad you were able to work it out. Minor point, though. Since you're already referencing the active document using the "With/End With" statement, you can replace...

Code:
Word.ActiveDocument.Saved = True

with

Code:
.Saved = True
 
Upvote 0

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
That's great, I'm glad you were able to work it out. Minor point, though. Since you're already referencing the active document using the "With/End With" statement, you can replace...

Code:
Word.ActiveDocument.Saved = True

with

Code:
.Saved = True

Ok, I'll give that a try. I may have misinformation that that syntax didn't work for some reason.

Edit: And that would be the case. Don't believe everything I read. Thanks again!
 
Last edited:
Upvote 0

Forum statistics

Threads
1,216,101
Messages
6,128,838
Members
449,471
Latest member
lachbee

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