UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> Object variable or With Block variable not set    
 
   
Topio
post May 22 2007, 12:31 AM
Post #1

UtterAccess Enthusiast
Posts: 80



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
Go to the top of the page
 
+
KingMartin
post May 22 2007, 12:43 AM
Post #2

Retired Moderator
Posts: 10,959
From: Prague,CZ / Kiev,UA



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
Go to the top of the page
 
+
Topio
post May 22 2007, 12:48 AM
Post #3

UtterAccess Enthusiast
Posts: 80



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!
Go to the top of the page
 
+
KingMartin
post May 22 2007, 12:53 AM
Post #4

Retired Moderator
Posts: 10,959
From: Prague,CZ / Kiev,UA



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
Go to the top of the page
 
+
Topio
post May 22 2007, 12:56 AM
Post #5

UtterAccess Enthusiast
Posts: 80



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?
Go to the top of the page
 
+
KingMartin
post May 22 2007, 01:08 AM
Post #6

Retired Moderator
Posts: 10,959
From: Prague,CZ / Kiev,UA



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
Go to the top of the page
 
+
Topio
post May 22 2007, 01:11 AM
Post #7

UtterAccess Enthusiast
Posts: 80



yeah i have found this page but i still cant seem to paste the range in as an image ?
Go to the top of the page
 
+
Topio
post May 22 2007, 01:13 AM
Post #8

UtterAccess Enthusiast
Posts: 80



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
Go to the top of the page
 
+

Thank you for your support! Reply to this topicStart new topic

Jump To Forum:
 



RSS Go to Top  ·  Lo-Fi Version Time is now: 23rd May 2013 - 01:46 PM