Link to home
Start Free TrialLog in
Avatar of Bianchi928
Bianchi928

asked on

Create PDF

How can I  modity this script to create a pdf with some fancy fonts instead of txt

Thanks
Cheers


Dim objWMIService, objitem, colitems, objFSO, strFile, objFile
Const ForWriting = 2
Const CreateIfNotExist = True

Set objExcel = CreateObject("Excel.Application")
Set objWorkbook = objExcel.Workbooks.Open("C:\Documents and Settings\Administrator\Desktop\xlsbillfile.xls")

intRow = 2

Do Until objExcel.Cells(intRow,1).Value = ""
   strFile = "C:\Documents and Settings\Administrator\Desktop\Phone Bills\" & objExcel.Cells(intRow, 4).Value & ".txt"
   Set objFSO = CreateObject("Scripting.FileSystemObject")
   Set objFile = objFSO.OpenTextFile(strFile, ForWriting, CreateIfNotExist)
   objFile.WriteLine "Mobile Phone Usage for the month of March 2012"
   objfile.WriteLine ""
   objfile.WriteLine "Mobile NUmber :" & objExcel.Cells(intRow, 1).Value
   objfile.WriteLine "Amount        :" & "$" & objExcel.Cells(intRow, 2).Value
   intRow = intRow + 1
Loop

objExcel.Quit
objfile.close
Wscript.echo "Job Done"
Avatar of themrrobert
themrrobert
Flag of United States of America image

You will need an extra 3rd party library to create a pdf file with vb or vba scripting.

Here is one: http://bytescout.com/products/developer/pdfdocscoutsdk/pdfdocscout_example_vbscript.html
Avatar of tampnic
Why not print the excel sheet through a PDF print driver?

http://www.cutepdf.com/products/cutepdf/writer.asp
http://www.bullzip.com/products/pdf/info.php

Cheers,
    Chris
Avatar of Bianchi928
Bianchi928

ASKER

Thanks for that. That's where I need help. I have a printer called FinePrint PDFFactory and I want to automate the printing. I don't want any user interaction.
I found this while trawling Google

http://blogs.technet.com/b/heyscriptingguy/archive/2010/09/06/save-a-microsoft-excel-workbook-as-a-pdf-file-by-using-powershell.aspx

Does it fit your requirement?

If not, then Googling for "Powershell print office document" should turn up the code you need.

Cheers,
    Chris
HI Chris,

You got me on the right track. I found this little Powershell thing that workjs only for one file

$word = new-object -ComObject "word.application"
$doc = $word.documents.open("C:\document.doc")
$saveaspath = [ref] "c:\document.pdf"
$formatPDF = [ref] 17
$doc.SaveAs($saveaspath,$formatPDF)
$doc.Close()


How can I modify to make it read & convert all the *.doc file from a directory tp pdf
ASKER CERTIFIED SOLUTION
Avatar of tampnic
tampnic
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Oops I found the problem to the script
Thanks