Page 1 of 1

Automatic file print script...??

Posted: Wed Jul 05, 2006 12:23 pm
by EnRoj
Hello sir, I'd like to know if I can print a file automatically after Ascendis registers a new call and if that's possible how can I do it?

Thanks a lot,
Enrique

Re: Automatic file print script...??

Posted: Wed Jul 05, 2006 2:45 pm
by Bill Root
Hello Enrique,

What kind of file would you like to print?

If the program that created the file has a command line print option, like Windows Notepad, you can do it with an advanced script such as this:

Code: Select all

// LANGUAGE=DWS

Log('temp.txt', 'ABCDEFG');
Run('notepad.exe', '/p temp.txt');
Note that the above script uses the "Log" command to put something into the file. If you have an existing file, you don't need this.

Finest regards,
Bill Root
Ascendis Software

Excel file automatically print

Posted: Thu Jul 13, 2006 2:48 pm
by EnRoj
Well, I'd like to print a file from Excel but I think that this program doesn't recognize the /p command...

Is there any other command or script that I can use?

Thanks agian.

Enrique

Re: Excel file automatically print

Posted: Thu Jul 13, 2006 8:12 pm
by Bill Root
I couldn't find a command-line option for Excel, either. But, I did find the following:

Code: Select all

' from http://groups.google.com/group/microsoft.public.excel.misc/msg/88267cfecdb4fd9c?dmode=source
' Author: Steve Yandl
'
' Print an Excel XLS file

Const xlDoNotSaveChanges = 2 

Dim fso, oXL, oWkbk 

Set fso = CreateObject("Scripting.FileSystemObject") 
Set oXL = CreateObject("Excel.Application") 

oXL.Visible = False 

If WScript.Arguments.Count = 0 Then 
WScript.Quit 
Else 
   For A = 0 To (WScript.Arguments.Count - 1) 
   If (Right(WScript.Arguments.Item(A), 3) = "xls")  _ 
   AND fso.FileExists(WScript.Arguments.Item(A)) Then 
      Set oWkbk = oXL.Workbooks.Open(WScript.Arguments.Item(A)) 
      oWkbk.PrintOut 
      oWkbk.Close xlDoNotSaveChanges 
   End If 
   Next 
End If 

oXL.Quit 
Set fso = Nothing 
Set oXL = Nothing
Put the above code into a file named 'PrintXls.vbs'. Save it somewhere convenient.

Now, use this script from Ascendis Caller ID to print:

Code: Select all

// LANGUAGE=DWS

// print from Excel:
// replace "c:\transfer\" with the location of PrintXLS.vbs
// replace "c:\transfer\temp.xls" with the name of the Excel file to print
Run('c:\transfer\PrintXLS.vbs', 'c:\transfer\temp.xls');
That worked in my tests. It requires Windows Script Host, which is installed by default on recent versions of Windows, I think. See the URL in the first script for more information.

Finest regards,
Bill Root
Ascendis Software

THANKS!!!

Posted: Fri Jul 14, 2006 9:59 am
by EnRoj
That's perfect!!! :D

Thank you very much sir!!!

Enrique

Re: THANKS!!!

Posted: Fri Jul 14, 2006 11:46 am
by Bill Root
You are most welcome! :D

-Bill