CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Nov 2005
    Location
    Omaha, Nebraska, USA
    Posts
    696

    Lotus Notes and UI

    I'll leave this post as reference just in case anyone needs this information, then answer myself:

    ===========================================
    I'm attempting to implement the NotesUIWorkspace and NotesUIDocument through Visual Basic to print the currently opened document.

    I can get so far as to set the Workspace and UIDocument correctly, while Notes and the document in question are open, but I get an error when I try to Print via the UIDocument object.

    With Notes loaded and the document in question already opened:
    Code:
    Option Explicit
    
    Private oleWorkspace As Object
    Private oleUIDoc As Object
    
    Private Sub Form_Load()
        Set oleWorkspace = CreateObject("Notes.NotesUIWorkspace")
        Set oleUIDoc = oleWorkspace.CurrentDocument
        If oleUIDoc Is Nothing Then
            MsgBox "Couldn't Open"
        Else
            oleUIDoc.Print   'This line gives an error
        End If
    End Sub
    
    Private Sub Form_Unload(Cancel As Integer)
        Set oleUIDoc = Nothing
        Set oleWorkspace = Nothing
    End Sub
    The error I'm getting is "438: Object doesn't support this property or method"

    I can try "? oleUIDoc.Print" in the Immediate pane and that works, but just "oleUIDoc.Print" doesn't, and if I try to write it as "Call oleUIDoc.Print" in the code, it removes Call.

    Trying the parameters of NotesUIDocument's Print method also gives an error, so I assume it has something to do with some default method called Print.

    Right now I'm implementing this code through a Standard EXE.

    Any ideas on how to correct this?
    ===========================================

    Method to correct this:
    Code:
    Option Explicit
    
    Private oleWorkspace As Object
    Private oleUIDoc As Object
    
    Private Sub Form_Load()
        Set oleWorkspace = CreateObject("Notes.NotesUIWorkspace")
        Set oleUIDoc = oleWorkspace.CurrentDocument
        If oleUIDoc Is Nothing Then
            MsgBox "Couldn't Open"
        Else
            On Error Resume Next
            Print oleUIDoc.Print(0, 0, 0, False)
        End If
    End Sub
    
    Private Sub Form_Unload(Cancel As Integer)
        Set oleUIDoc = Nothing
        Set oleWorkspace = Nothing
    End Sub
    This will automatically print the currently open document.

    If you use a printer driver that saves a file instead of prints a hard copy (like the Microsoft Office Document Image Writer), VB will halt until you switch to Lotus Notes and tell it where to save. Pressing Cancel will give a printer error that can loop back to Visual Basic (hence, the On Error Resume Next).
    Last edited by ChaosTheEternal; December 14th, 2005 at 12:42 PM. Reason: Forehead... *smack*

  2. #2
    Join Date
    Aug 2009
    Posts
    1

    Question Re: Lotus Notes and UI

    Hello, I tried this method, and I also got an error in below sentence:
    Print oleUIDoc.Print(0, 0, 0, False)
    And what I need is to print the document background, is there any way to print the Notesdocument Object, not notesuidocment Object.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured