Solved

how & where?

Posted on 2003-10-22
4
218 Views
Last Modified: 2013-12-18
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.Network")
PrinterPath = "HP LaserJet 2100 Series PCL 6"
WshNetwork.SetDefaultPrinter 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];@MailDbName;"Memo");
FIELD EnterSendTo := _SendTo;
FIELD SendTo := _SendTo;
@Command([EditGotoField]; "Body" );
@Command([EditInsertFileAttachment];"c:\\tempexport.doc";false)

??
 



0
Comment
Question by:Collenr
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 9

Expert Comment

by:Arunkumar
ID: 9599140
Well, after setting the default printer you need to print the stuff using FilePrint.

This will print to the pdf file.  You cannot export to a pdf writer.

You can only print.
0
 
LVL 15

Expert Comment

by:Bozzie4
ID: 9601052
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
0
 
LVL 31

Accepted Solution

by:
qwaletee earned 50 total points
ID: 9602549
"Found" a free PDF Writer?  I pointed one out to you in the previous Q!

Anyway, first you have to know where the output file goes.  For teh free PDF utility I gave you, I think you have to set a variable in an INI file.  You also have to wait for teh file to be complete -- you don't want to e-Mail a file-in-progress!

The following code will e-Mil a given file:

Dim s as new notesSession
Dim db as notesDatabase
Set db = s.currentDatabase
Dim doc as notesDocument
Set doc = s.documentContext 'you may need to assign this to something else
Dim memo as new NotesDocument(db)
memo.Form = "Memo"
memo.Subject = "Yuor PDF version of the Notes document"
memo.SendTo = doc._SendTo
Dim body as notesRichTextItem
Set body = memo.createRichTextItem("Body")
body.embedObject EMBED)ATTACHMENT , "" , "c:\tempexport.doc"
memo.send false
0
 

Expert Comment

by:Anita_White
ID: 39521309
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("@AttachmentNames",doc)
            antalfiler=Evaluate("@Attachments", 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.universalid,4)+"___"
                              End If
                              Call object.ExtractFile (downloadfolder+"\"+extrachar+ filen(filecounter) )
                        End If
                  Next filecounter
            End If
            
            For y = 0 To filecounter-1
                  sFile = downloadfolder+"\"+extrachar+ 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+"\"+extrachar+ filen(y)
                  Kill sFile
            Next
            
'Call TerminateProcess(SEI.hProcess, 0)
            
      Next
      
      Exit Sub
      
ErrorHandler:
      Msgbox Error$ & " on line " & Cstr(Erl) & " in " & Lsi_info(12)
      Exit Sub
End Sub
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I thought it will be a good idea to make a post as it will help in case someone else faces these issues. I trust this gives an idea how each entry in Notes.ini can mean a lot for the Domino Server to be functioning properly. This article discusses t…
  In today’s Arena we can’t imagine our lives without Internet as we are highly used to of it. If we consider our life style just for only 2 min we found that face to face communication is swapped by e-communication.  Every Where from Works place to…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

689 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question