Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Print/convert Word to PDF

Status
Not open for further replies.

CooterBrown

IS-IT--Management
Aug 17, 2001
125
US
Hello All... I've searched the forum and found posts that are helpful but not 100% what I need. I have the following existing code that prints a bunch of .docs to the default printer. I have Adobe Acrobat Pro 6.0 installed with the adobe printer set as default on my machine (this runs locally). I need to modify this code so that these docs can be converted/printed to PDF by passing a parameter to name the file (ie..not use save dialog box for each file.)
This is a Macro in Excel but I can create an executable in VB6.0 if I have to:



Sub getinfo()

Dim oFs As New FileSystemObject
Dim oFolder As Folder
Dim oFile As File

folderspec = "C:\Test\quikdocs"
If oFs.FolderExists(folderspec) Then
Set oFolder = oFs.GetFolder(folderspec)


Range("A2").Select
Do Until ActiveCell.Value = " " Or ActiveCell.Value = Empty

PolicyNumber = ActiveCell.Value
Call Addzeros(PolicyNumber, 9)

record = Trim(PolicyNumber)
Document = ActiveCell.Offset(0, 5)
Document = folderspec & "\" & Document
Call worddox(Document)


PolicyNumber = ""
record = ""
Document = ""


ActiveCell.Offset(1, 0).Select
Loop

End If
End Sub
Sub AddBlnks(line, Length)
Do Until Len(line) >= Length
line = line & " "
Loop
End Sub
Sub AddLeadingBlnks(line, Length)
Do Until Len(line) >= Length
line = " " & line
Loop
End Sub
Sub Addzeros(line, Length)
Do Until Len(line) >= Length
line = "0" & line
Loop
End Sub


Public Sub worddox(txthyperlink)
Dim pWordApp As Word.Application
Dim pWordDoc As Word.Document

Set pWordApp = New Word.Application

'On Error Resume Next
Set pWordDoc = pWordApp.Documents.Open(txthyperlink)
'On Error GoTo ERR_ALERT

If Not pWordDoc Is Nothing Then
pWordApp.Visible = False
pWordDoc.PrintOut
pWordDoc.Activate
pWordDoc.Close
Set pWordDoc = Nothing
End If
Exit Sub


ERR_ALERT:
Set pWordDoc = Nothing
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top