+ Reply to Thread
Results 1 to 5 of 5

Thread: Object Variable or With Block Variable Not Set

  1. #1
    Registered User
    Join Date
    01-10-2012
    Location
    milano
    MS-Off Ver
    Excel 2003
    Posts
    2

    Object Variable or With Block Variable Not Set

    Hi everybody.

    I get error "Run 91" - Object Variable or With Block Variable Not Set when i try to send an email with Lotus Notes, using an Excel Userform.

    Here's my code:

    Sub LotusMail_Click()
        Dim NSession As Object
        Dim NUIWorkSpace As Object
        Dim NDoc As Object
        Dim NUIdoc As Object
        Dim Maildb As Object ' The mail database
    Dim UserName As String 'The users notes name
    Dim MailDbName As String ' The users notes mail database name
        
        cbxOnTop.Value = False
        Select Case MsgBox("blablabl", vbOKCancel Or vbQuestion Or vbDefaultButton1, "aaa")
        Case vbOK
        Application.WindowState = xlMaximized
        Windows("ORDINI DHL.xls").Activate
        Sheets("1").Select
        Range("a1").Select
        cbxOnTop.Value = True
        Set NSession = CreateObject("Notes.NotesSession")
        UserName = NSession.UserName
    MailDbName = Left$(UserName, 1) & Right$(UserName, (Len(UserName) - InStr(1, UserName, " "))) & ".nsf"
    'Open the mail database in notes
    Set Maildb = NSession.GETDATABASE("", "")
    If Maildb.IsOpen = True Then
    'Already open for mail
    Else
    Maildb.OpenMail
    End If
        Set NUIWorkSpace = CreateObject("Notes.NotesUIWorkspace")
        
        Set NDoc = NUIWorkSpace.ComposeDocument("", "", "Memo")
        Set NUIdoc = NUIWorkSpace.CURRENTDOCUMENT
        
        With NUIdoc
           .FieldSetText "EnterCopyTo", ""  <------
            .FieldSetText "Subject", "Hello "
            .FieldSetText "Body", "" & Me.txtPappa.Value & Me.txtPip.Value
            .GotoField ("Body")
            .FieldSetText "EnterSendTo", "me@hotmail.com"
            Application.CutCopyMode = False
        .send
        .Close
            
        End With
        
        Set NUIdoc = Nothing
        Set NDoc = Nothing
        Set NUIWorkSpace = Nothing
        Set NSession = Nothing
    End Sub

    Everytime i try to send an email, the error focuses on the first .FieldSetText.

    I really hope you could help me.
    Thanks a lot.
    Last edited by TMShucks; 01-10-2012 at 02:23 PM.

  2. #2
    Forum Guru Mordred's Avatar
    Join Date
    07-06-2010
    Location
    Winnipeg, Canada
    MS-Off Ver
    2007, 2010
    Posts
    2,276

    Re: Object Variable or With Block Variable Not Set

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code. Posting code without them makes your code hard to read and difficult to be copied for testing. Highlight your code and click the # at the top of your post window. For more information about these and other tags, found here
    Please leave a message after the beep!

  3. #3
    Forum Guru TMShucks's Avatar
    Join Date
    07-15-2010
    Location
    Manchester, England
    MS-Off Ver
    MSO 2003 & 2007
    Posts
    6,230

    Re: Object Variable or With Block Variable Not Set

    I think you need an "End Select" before the End Sub.

    Difficult to test with no workbook (and no Lotus Notes)


    Please note that:

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code. Posting code without them makes your code hard to read and difficult to be copied for testing. Highlight your code and click the # at the top of your post window. For more information about these and other tags, found here


    However, on this occasion, I have corrected this for you.

    Regards, TMS

  4. #4
    Forum Guru TMShucks's Avatar
    Join Date
    07-15-2010
    Location
    Manchester, England
    MS-Off Ver
    MSO 2003 & 2007
    Posts
    6,230

    Re: Object Variable or With Block Variable Not Set

    @Mordred: sorry! I was in the process of "fixing and answering" for the new user. Didn't mean to tread on your toes

  5. #5
    Registered User
    Join Date
    01-10-2012
    Location
    milano
    MS-Off Ver
    Excel 2003
    Posts
    2

    Re: Object Variable or With Block Variable Not Set

    Sorry guys! Next i will surely use the tags.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.2.0