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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

convert word to .ps file 2

Status
Not open for further replies.

susanh

MIS
Jan 16, 2001
229
US
Is there a way to convert word files to ps files without buying any software?
Thanks
Sue
 
hmmmm.. I must be doing something incorrectly. I installed the postscript printer and print to file and it still comes up as a .prn file. Maybe I installed the printer incorrectly?
 
I think that would work great if it was a one or two time deal, but I was trying to establish a new work procedure which would involve lots and lots of word files.
 
this simple MS Word macro will print the active document to a file named E:\test.ps

tested on MS Word XP

replace Acrobat Distiller with the name of your (dummy) PostScript printer
replace E:\test.ps with your desired filename

if you need help setting this up, just holler (also if you need help modifying/customizing the macro)

[tt]Option Explicit

Sub test()
Dim doc As Word.Document
Dim old As String

old = Application.ActivePrinter

Application.ActivePrinter = "Acrobat Distiller"
Set doc = ActiveDocument
doc.PrintOut False, False, , "E:\test.ps", , , , , , , True
Set doc = Nothing

Application.ActivePrinter = old
End Sub[/tt]
 
Great! I will give a shot. I will let you know. Thank you for all the help. I appreciate. Have a great day.
 
Install a new local printer, and choose to use a driver like the "Apple LaserWriter Pro" (good PS print driver). Don't check the "Print to File" box. But rather point the port to "C:\some directory\Postscript.ps" When you print to this printer it will make a PS file with the name Postscript.ps. You'll just have rename the file after each print to avoid replacing the previous print job.

It's easy to do in VB or C.

If you check the "Print to File" it will always come out as a PRN file!
 
Justin,
This works great!!! Thank You. Is there a way to modify this part of the macro
"doc.PrintOut False, False, , "E:\test.ps", , , , , , , True"
to automatically save the file as file name?
So, if i have a word document named herman.doc and I hit the macro can I tell this macro to save the file as herman.ps?
 
[tt]Option Explicit

Sub test()
Dim doc As Word.Document
Dim old As String

old = Application.ActivePrinter

Application.ActivePrinter = "Acrobat Distiller"
Set doc = ActiveDocument
doc.PrintOut False, False, , PSFileName, , , , , , , True
Set doc = Nothing

Application.ActivePrinter = old
End Sub

Private Function PSFileName() As String
Dim oFSO As Object
Dim sDocFile As String
Dim sPath As String
Dim sName As String

sDocFile = ActiveDocument.FullName

Set oFSO = CreateObject("Scripting.FileSystemObject")
sPath = oFSO.GetParentFolderName(sDocFile)
sName = oFSO.GetBaseName(sDocFile) ' sans extension
PSFileName = oFSO.BuildPath(sPath, sName) & ".ps"
Set oFSO = Nothing
End Function
[/tt]
 
Good Morning,
We have been using the following macro that JustinEzequiel was so kind to write up for me last year, which works fantastic. Now, I would like to take this macro a step further and was wondering if someone could help.

Like the above code:
Sub convert()

Dim doc As Word.Document
Dim old As String

old = Application.ActivePrinter

Application.ActivePrinter = "Generic Postscript Printer"
Set doc = ActiveDocument
doc.PrintOut False, False, , PSFileName, , , , , , , True
Set doc = Nothing

Application.ActivePrinter = old
End Sub

Private Function PSFileName() As String
Dim oFSO As Object
Dim sDocFile As String
Dim sPath As String
Dim sName As String

sDocFile = ActiveDocument.FullName

Set oFSO = CreateObject("Scripting.FileSystemObject")
sPath = oFSO.GetParentFolderName(sDocFile)
sName = oFSO.GetBaseName(sDocFile) ' sans extension
PSFileName = oFSO.BuildPath(sPath, sName) & ".ps"
Set oFSO = Nothing
End Function


Is there a way to modify this macro so it saves the .doc file to a certain directory and then saves the .ps file to a different specified directory?


Thanks
Sue

 
Greetings Sue,

Am busy at the moment but will see if I can spare some time.

Do the folders change every time for each run or are they fixed?

Justin
 
No they would stay the same. I have tried to modify it myself but I just can't get it to do it.
 
enjoy...
any chance of you offering me a job?:)

Code:
Sub convert()

    Dim doc As Word.Document
    Dim old As String
    Dim docpath As String
    Dim pspath As String
    Dim newdoc As String
    Dim psfile As String
    
    docpath = "C:\temp"
    pspath = "C:\tmp"
    
    old = Application.ActivePrinter
    
    Application.ActivePrinter = "Generic Postscript Printer"
    Set doc = ActiveDocument
    
    newdoc = DestPath(docpath, doc.Name)
    psfile = DestPath(pspath, PSName(doc.Name))

    doc.SaveAs newdoc
    
    doc.PrintOut False, False, , psfile, , , , , , , True
    Set doc = Nothing
    
    Application.ActivePrinter = old
End Sub

Private Function DestPath(sPath As String, sName As String) As String
    Dim oFSO As Object
    
    Set oFSO = CreateObject("Scripting.FileSystemObject")
    DestPath = oFSO.BuildPath(sPath, sName)
    Set oFSO = Nothing
End Function

Private Function PSName(sDocName As String) As String
    Dim oFSO As Object
    Dim sName As String
    
    Set oFSO = CreateObject("Scripting.FileSystemObject")
    sName = oFSO.GetBaseName(sDocName) ' strip extension
    PSName = sName & ".ps"
    Set oFSO = Nothing
End Function
 
No. I'm in the Philippines.
Will holler if ever I am in the US of A again.
Was in Las Vegas last November.
 
Yes do! Thanks Again. I appreciate it :) Have a great day!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top