Full Version: Object variable or With Block variable not set
UtterAccess Discussion Forums > Microsoft® Office > Microsoft Excel
Topio
Hi All,

Think I have almost cracked the "paste" into Lotus note problem.

EXCEPT I keep getting the above error! Can someone please help me decifer what I am doing wrong!?

Thanks!

CODE
  Sub SendMail()



On Error GoTo Ett_Trap



    Dim nDB As Object

    Dim nDoc As Object

    Dim nSession As Object

    Dim nRichTextItem As Object

    Dim nRichTemItem2 As Object

    Dim nAttachment As Object

    Dim nPicture As Object

    Dim strTo As String

    Dim strCC As String

    Dim strBCC As String

    Dim strAttachment As String

    Dim strPicture As String

    Dim ws As NOTESUIWORKSPACE

    Dim uidoc As Object



'Fill Body of Email

    strSubject = txtCustName.Text & " " & txtCustNo.Text

    

'Attachments

    strAttachment = ActiveWorkbook.FullName

    

'Copy Screen

    Sheet4.Range("A1:P23").CopyPicture xlScreen, xlBitmap



'Call Lotus Notes

    Set nSession = CreateObject("Notes.Notessession")

    Set nDB = nSession.GetDatabase("", "")

    Call nDB.OPENMAIL

    Set nDoc = nDB.CreateDocument

    

'Add Attachemnt file to email if passed

    Set nRichTextItem = nDoc.CreateRichTextItem("Attachment")

    Set nAttachment = nRichTextItem.EmbedObject(EMBED_ATTACHMENT, "", strAttachment)

    

'Paste Picture

    Set uidoc = ws.EDITDOCUMENT

    Call uidoc.GOTOFIELD("body")

    Call uidoc.Paste

        

'Set Values of Email

    Call nDoc.ReplaceItemValue("Subject", strSubject)



'Call nDoc.Send(False) 'Comment to not send email and save to drafts

    'Call nDoc.Save(True, True)

     'Call nDoc.Save(False, False)

     Set nDoc = Nothing



Ett_Trap_Exit:

    Exit Sub

    

Ett_Trap:

    MsgBox Err.Description

    Resume Ett_Trap_Exit



End Sub
KingMartin
Hello,

you don't say which line barfs but for example I don't see where you initialize the ws object pointer before use:

Set uidoc = ws.EDITDOCUMENT

Martin
Topio
Hi Martin,

How would I go about fixing this (this is the line)

I just need bit of help with pasting the copied picture in the body of the mail ?

thanks!
KingMartin
Hello,

the problem is that I don't know the LN object model and this variable comes exactly from the Lotus Notes realm:

Dim ws As NOTESUIWORKSPACE

(obviously)

You must use something like

Set ws = CreateObject("ClassNamehere")

or try (as you have obviously early-binding with the reference to the object model of Lotus set in advance)

Dim ws As New NotesUIWorkspace

Martin
Topio
Yeah I cant use Dim ws as NEW NotesUIWORKSPACE because it errors

I am using Excel 2000 and its says "invalid use of new keyword"?

Not sure y?
KingMartin
Too bad I can't test this...

For example this site uses the syntax I have posted.

You have set a reference to the Lotus Notes library, didn't you? (Otherwise you'd get a different error type though, 'user type not defined'.)

Could you find some sample code with google?

Martin
Topio
yeah i have found this page but i still cant seem to paste the range in as an image ?
Topio
When I change it to:

Dim workspace As NOTESUIWORKSPACE
Dim uidoc As NOTESUIDOCUMENT

'Paste Picture
Set uidoc = workspace.CURRENTDOCUMENT
Call uidoc.GOTOFIELD("Body")
Call uidoc.Paste

I get same error
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.