Collenr
asked on
how & where?
Ok,
I have found a FREE PDF writer, I want to print to that PDF writer from NOTES, then in the same breath, email the PDF in the same breath basically!
Dim WshNetwork As Variant
Set WshNetwork = CreateObject("WScript.Netw ork")
PrinterPath = "HP LaserJet 2100 Series PCL 6"
WshNetwork.SetDefaultPrint er PrinterPath
Set WshNetwork = Nothing
If this is the code to change a printer default to a printer specify, where do I put this code and how would I be able to combine the below code with...
_SendTo := SendTo;
@Command( [FileExport];"WordPerfect" ; "c:\\tempexport.doc" );
@Command([Compose];@MailDb Name;"Memo ");
FIELD EnterSendTo := _SendTo;
FIELD SendTo := _SendTo;
@Command([EditGotoField]; "Body" );
@Command([EditInsertFileAt tachment]; "c:\\tempe xport.doc" ;false)
??
I have found a FREE PDF writer, I want to print to that PDF writer from NOTES, then in the same breath, email the PDF in the same breath basically!
Dim WshNetwork As Variant
Set WshNetwork = CreateObject("WScript.Netw
PrinterPath = "HP LaserJet 2100 Series PCL 6"
WshNetwork.SetDefaultPrint
Set WshNetwork = Nothing
If this is the code to change a printer default to a printer specify, where do I put this code and how would I be able to combine the below code with...
_SendTo := SendTo;
@Command( [FileExport];"WordPerfect"
@Command([Compose];@MailDb
FIELD EnterSendTo := _SendTo;
FIELD SendTo := _SendTo;
@Command([EditGotoField]; "Body" );
@Command([EditInsertFileAt
??
No need to export. Just do EditInsertFileAttachment with the file you create.
To tie the 2 together, you could put the @formula's in an agent, and call that agent from your script (in a button) like :
...
set s = new notessession
set db = s.currentdatabase
set agent = db.getAgent( "AgentName" )
Call agent.run()
cheers,
Tom
To tie the 2 together, you could put the @formula's in an agent, and call that agent from your script (in a button) like :
...
set s = new notessession
set db = s.currentdatabase
set agent = db.getAgent( "AgentName" )
Call agent.run()
cheers,
Tom
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Here is the code:
OPTIONS
Option Public
Uselsx "*lsxlc"
DECLARATIONS
Const SEE_MASK_NOCLOSEPROCESS = &H40
Const SEE_MASK_FLAG_NO_UI = &H400
Private Type SHELLEXECUTEINFO
cbSize As Long
fMask As Long
hwnd As Long
lpVerb As String
lpFile As String
lpParameters As String
lpDirectory As String
nShow As Long
hInstApp As Long
lpIDList As Long
lpClass As String
hkeyClass As Long
dwHotKey As Long
hIcon As Long
hProcess As Long
End Type
Declare Function ShellExecuteEx Lib "shell32.dll"_
Alias "ShellExecuteEx" (SEI As SHELLEXECUTEINFO) As Long
Declare Function TerminateProcess Lib "kernel32"_
Alias "TerminateProcess" (Byval hProcess As Long, Byval uExitCode As Long) As Long
INITIALIZE
Sub Initialize
On Error Goto ErrorHandler
Dim SEI As SHELLEXECUTEINFO
SEI.cbSize = Len(SEI)
SEI.fMask = SEE_MASK_NOCLOSEPROCESS Or SEE_MASK_FLAG_NO_UI
SEI.lpVerb = "print"
SEI.nShow = 1
SEI.hInstApp = 0
SEI.lpIDList = 0
Dim s As New NotesSession
Dim session As New LCSession
Dim db As NotesDatabase
Dim object As NotesEmbeddedObject
Dim dc As NotesDocumentCollection
Dim doc As NotesDocument
Dim downloadfolder As String
Dim extrachar As String
Dim filecounter As Integer
Dim filecount As Integer
Dim filen As Variant
Dim antalfiler As Variant
Dim i As Integer, x As Integer, y As Integer
Dim sFile As String
Dim uidoc As NotesUIDocument
Dim ws As New NotesUIWorkspace
Dim success As Variant
' Create a folder for temporary storage of files
downloadfolder = Environ("tmp")
Set db = s.CurrentDatabase
Set dc = db.UnprocessedDocuments
For i = 1 To dc.Count
Set doc = dc.GetNthDocument( i )
' Print document
Set uidoc = ws.EditDocument( False , doc , True , )
Call uidoc.Print(1)
' Get all attachments and print them
filen=Evaluate("@Attachmen tNames",do c)
antalfiler=Evaluate("@Atta chments", doc)
Call uidoc.Close
Delete uidoc
If antalfiler(0)>0 Then
For filecounter=0 To antalfiler(0)-1
x=x+1
Set Object = doc.GetAttachment( filen(filecounter) )
If ( object.Type = EMBED_ATTACHMENT ) Then
fileCount = fileCount + 1
If Dir(downloadfolder+"\"+ filen(filecounter))="" Then
extrachar=""
Else
' Extra character in case there are attachments with the same name
extrachar=Left(doc.univers alid,4)+"_ __"
End If
Call object.ExtractFile (downloadfolder+"\"+extrac har+ filen(filecounter) )
End If
Next filecounter
End If
For y = 0 To filecounter-1
sFile = downloadfolder+"\"+extrach ar+ filen(y)
SEI.lpFile = sFile
Call ShellExecuteEx(SEI)
Call session.Sleep(2000)
Next
' Delete all files
Call session.Sleep(5000)
For y = 0 To filecounter-1
sFile = downloadfolder+"\"+extrach ar+ filen(y)
Kill sFile
Next
'Call TerminateProcess(SEI.hProc ess, 0)
Next
Exit Sub
ErrorHandler:
Msgbox Error$ & " on line " & Cstr(Erl) & " in " & Lsi_info(12)
Exit Sub
End Sub
OPTIONS
Option Public
Uselsx "*lsxlc"
DECLARATIONS
Const SEE_MASK_NOCLOSEPROCESS = &H40
Const SEE_MASK_FLAG_NO_UI = &H400
Private Type SHELLEXECUTEINFO
cbSize As Long
fMask As Long
hwnd As Long
lpVerb As String
lpFile As String
lpParameters As String
lpDirectory As String
nShow As Long
hInstApp As Long
lpIDList As Long
lpClass As String
hkeyClass As Long
dwHotKey As Long
hIcon As Long
hProcess As Long
End Type
Declare Function ShellExecuteEx Lib "shell32.dll"_
Alias "ShellExecuteEx" (SEI As SHELLEXECUTEINFO) As Long
Declare Function TerminateProcess Lib "kernel32"_
Alias "TerminateProcess" (Byval hProcess As Long, Byval uExitCode As Long) As Long
INITIALIZE
Sub Initialize
On Error Goto ErrorHandler
Dim SEI As SHELLEXECUTEINFO
SEI.cbSize = Len(SEI)
SEI.fMask = SEE_MASK_NOCLOSEPROCESS Or SEE_MASK_FLAG_NO_UI
SEI.lpVerb = "print"
SEI.nShow = 1
SEI.hInstApp = 0
SEI.lpIDList = 0
Dim s As New NotesSession
Dim session As New LCSession
Dim db As NotesDatabase
Dim object As NotesEmbeddedObject
Dim dc As NotesDocumentCollection
Dim doc As NotesDocument
Dim downloadfolder As String
Dim extrachar As String
Dim filecounter As Integer
Dim filecount As Integer
Dim filen As Variant
Dim antalfiler As Variant
Dim i As Integer, x As Integer, y As Integer
Dim sFile As String
Dim uidoc As NotesUIDocument
Dim ws As New NotesUIWorkspace
Dim success As Variant
' Create a folder for temporary storage of files
downloadfolder = Environ("tmp")
Set db = s.CurrentDatabase
Set dc = db.UnprocessedDocuments
For i = 1 To dc.Count
Set doc = dc.GetNthDocument( i )
' Print document
Set uidoc = ws.EditDocument( False , doc , True , )
Call uidoc.Print(1)
' Get all attachments and print them
filen=Evaluate("@Attachmen
antalfiler=Evaluate("@Atta
Call uidoc.Close
Delete uidoc
If antalfiler(0)>0 Then
For filecounter=0 To antalfiler(0)-1
x=x+1
Set Object = doc.GetAttachment( filen(filecounter) )
If ( object.Type = EMBED_ATTACHMENT ) Then
fileCount = fileCount + 1
If Dir(downloadfolder+"\"+ filen(filecounter))="" Then
extrachar=""
Else
' Extra character in case there are attachments with the same name
extrachar=Left(doc.univers
End If
Call object.ExtractFile (downloadfolder+"\"+extrac
End If
Next filecounter
End If
For y = 0 To filecounter-1
sFile = downloadfolder+"\"+extrach
SEI.lpFile = sFile
Call ShellExecuteEx(SEI)
Call session.Sleep(2000)
Next
' Delete all files
Call session.Sleep(5000)
For y = 0 To filecounter-1
sFile = downloadfolder+"\"+extrach
Kill sFile
Next
'Call TerminateProcess(SEI.hProc
Next
Exit Sub
ErrorHandler:
Msgbox Error$ & " on line " & Cstr(Erl) & " in " & Lsi_info(12)
Exit Sub
End Sub
This will print to the pdf file. You cannot export to a pdf writer.
You can only print.