Any VBS/WSH coders out there?

Discussion in 'OT Technology' started by driftwell, Jun 27, 2005.

  1. driftwell

    driftwell New Member

    Joined:
    Oct 7, 2003
    Messages:
    220
    Likes Received:
    0
    I'm in need of a script of some sort that will print out (really fax using VSIFAX) a document/flyer from out of Word.

    The catch is that it needs to go out to all of our customers (1000's)... and hitting print.. and then entering the fax number would take forever.

    I already queried the fax numbers out of our database...

    now i just need a way to fax to these numbers...
     
  2. SLED

    SLED build an idiot proof device and someone else will

    Joined:
    Sep 20, 2001
    Messages:
    28,118
    Likes Received:
    0
    Location:
    AZ, like a bauce!
    It's really a matter of looking into the VSIFAX API (if they even have one) to see how to attach documents to a fax object, and send to specific numbers. The script should be really easy if you have the VSI documentation.
     
  3. Yep

    Yep Knick knack paddy whack, give the old dog a bone

    Joined:
    Jan 22, 2001
    Messages:
    4,603
    Likes Received:
    0
    Location:
    South Jersey
    It *should* be fairly easy to interface with Microsoft Word using some VBA API's. I say *should* because I've never done it before. Getting the print dialog to go to VSIFAX seems easy enough, but punching the number in and hitting print is more difficult in VBScript

    It would probably be much easier to do in Visual Basic, since I've never been able to find a way to use the SendMessage or PostMessage API's (to enter the phone number) with VBScript. Some have told me it's not possible due to security built into Windows.
     
  4. Yep

    Yep Knick knack paddy whack, give the old dog a bone

    Joined:
    Jan 22, 2001
    Messages:
    4,603
    Likes Received:
    0
    Location:
    South Jersey
    A start, but I think you'll have problems unless you can figure out how to make SendMessage and PostMessage work.

    SendKeys is an option but might be difficult to use.

    Const wdDoNotSaveChanges = 0

    sDocument = "C:\something.txt"

    ' if you want to have the document name as a command line
    ' input parameter, enable the two lines below
    'Set oArg = WScript.Arguments
    'sDocument = oArg.Item(0)

    ' printer that is to be used
    sPrinter = "some printer name here"

    With CreateObject("Word.Application")
    ' if you want to hide Word, set .Visible to False
    .Visible = True
    .Documents.Open(sDocument)
    .Options.PrintBackground = False
    ' get current active printer
    sActivePrinter = .Application.ActivePrinter
    ' set active printer
    .Application.ActivePrinter = sPrinter
    .ActiveDocument.PrintOut
    ' set current active printer back to original
    .Application.ActivePrinter = sActivePrinter
    ' quit without saving any changes
    .Application.Quit wdDoNotSaveChanges
    End With
     

Share This Page