backwaterdogs
asked on
NotesRichTextItem(doc, "string") not working, pls help
having all sorts of grief trying to get up to speed with the notes objects in VBA. In searching through all the examples and docs that I have the following should pose no problems, but the last line generates the following error: "compile error sub or function not defined" All the docs reference two arguments for this 'constructor' what am I missing? have tried late binding as well. thanks!
Dim session As New Domino.NotesSession
Dim db As New Domino.NotesDatabase
Dim doc As New Domino.NotesDocument
Dim dc As New Domino.NotesDocumentCollec tion
Call session.Initialize
Set db = session.GetDatabase("", "copy of testcoach.nsf")
Set dc = db.AllDocuments
Set doc = dc.GetNthDocument(421)
Set rtitem = NotesRichTextItem(doc, "ImageFilePath")
Dim session As New Domino.NotesSession
Dim db As New Domino.NotesDatabase
Dim doc As New Domino.NotesDocument
Dim dc As New Domino.NotesDocumentCollec
Call session.Initialize
Set db = session.GetDatabase("", "copy of testcoach.nsf")
Set dc = db.AllDocuments
Set doc = dc.GetNthDocument(421)
Set rtitem = NotesRichTextItem(doc, "ImageFilePath")
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Gents,
Thanks for the input! qwalatee, I tried as you suggested, but get an error on the document as the document already has the item "ImageFilePath". This is a field that stores a binary image file (embedded_attachment) and I am trying to figure out how to replace the image file.
I believe I need to somehow associate the RichTextITem to a field in the document, which the only way I see is using the NotesRichTextItem() (method/constructor or whatever this is). My next step is to then embed the attachment as described on several other entries.
Can you please help with this? What is the best/quickest method from VBA to update/replace an embedded attachment?
Thanks very much for your help and patience!
Thanks for the input! qwalatee, I tried as you suggested, but get an error on the document as the document already has the item "ImageFilePath". This is a field that stores a binary image file (embedded_attachment) and I am trying to figure out how to replace the image file.
I believe I need to somehow associate the RichTextITem to a field in the document, which the only way I see is using the NotesRichTextItem() (method/constructor or whatever this is). My next step is to then embed the attachment as described on several other entries.
Can you please help with this? What is the best/quickest method from VBA to update/replace an embedded attachment?
Thanks very much for your help and patience!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Well, actually, there is one way using OLE automation of the Notes client instead of COM access to the API.
ASKER
qwualetee,
thanks very much for this reply, been away for the last day or so, but i will try your suggestion asap. I believe I can use rtitm.EmbedObject(EMBED_AT TACHMENT.. ...) can't I?
Should have posted this earlier, but this is the lotus scipt that is currently running and that I am trying to port to VB:
Sub Initialize
Dim session As New NotesSession
Dim workspace As New notesuiworkspace
Dim uidoc As notesuidocument
Dim db As NotesDatabase
Dim doc As Notesdocument
Dim dc As Notesdocumentcollection
Dim object As NotesEmbeddedObject
Dim s As String
Dim i As Integer
Set db = session.CurrentDatabase
Set dc = db.UnProcessedDocuments ' Selected slides
If dc.count > 0 Then
For j = 1 To dc.Count
Set doc = dc.GetNthDocument(j)
' Set uidoc = workspace.currentdocument
' Set doc = uidoc.document
' filename = doc.filename(0)
' pre=Left(filename, 9)
' post=
newfiles = "c:\vc files\" & "Slide" & doc.SlideNumber(0) & ".PNG"
Set rtitem = New NotesRichTextItem( doc,"ImageFilePath" )
Set object = rtitem.EmbedObject _
( EMBED_ATTACHMENT, "", newfiles)
Call doc.Save( True, True )
Print " We are on # " & j & " .... Speed demon"
Next j
Print "Successfully added files. "
End If
End Sub
Any more help on porting this is greatly appreciated. John
thanks very much for this reply, been away for the last day or so, but i will try your suggestion asap. I believe I can use rtitm.EmbedObject(EMBED_AT
Should have posted this earlier, but this is the lotus scipt that is currently running and that I am trying to port to VB:
Sub Initialize
Dim session As New NotesSession
Dim workspace As New notesuiworkspace
Dim uidoc As notesuidocument
Dim db As NotesDatabase
Dim doc As Notesdocument
Dim dc As Notesdocumentcollection
Dim object As NotesEmbeddedObject
Dim s As String
Dim i As Integer
Set db = session.CurrentDatabase
Set dc = db.UnProcessedDocuments ' Selected slides
If dc.count > 0 Then
For j = 1 To dc.Count
Set doc = dc.GetNthDocument(j)
' Set uidoc = workspace.currentdocument
' Set doc = uidoc.document
' filename = doc.filename(0)
' pre=Left(filename, 9)
' post=
newfiles = "c:\vc files\" & "Slide" & doc.SlideNumber(0) & ".PNG"
Set rtitem = New NotesRichTextItem( doc,"ImageFilePath" )
Set object = rtitem.EmbedObject _
( EMBED_ATTACHMENT, "", newfiles)
Call doc.Save( True, True )
Print " We are on # " & j & " .... Speed demon"
Next j
Print "Successfully added files. "
End If
End Sub
Any more help on porting this is greatly appreciated. John
Since you don't use NEW< VBA is assuming that you must have a built-in, add-on, or you own defined function named NotesRichTextItem
------------
The help for NotesRichTextItem describes creating it via NEW or via NotesDocument.CreteRichTex
set rtitem = doc.createRichTextItem(doc
-----------
Is 421 significant to you, or a random pick? Just to let yu know, if you loop over a collection, it is MUCH more efficient to use getFirstDocument/getNextDo