I found some threads in the 4&5 Forum (http://www-10.lotus.com/ldd/46dom.nsf/55c38d716d632d9b8525689b005ba1c0/de00d1befd0617cf85256a45005b9d34?OpenDocument&Highlight=0,gotof%3Feld), tried the ideas/solutions, but I still get the same error: “Cannot locate field.”
I have copied a script routine from Lotus’ Microsoft Office Library Template and am using it in my own database. The routine is from the “OLERoutines” script library called “GetOrCreateOLEObject.”
I have copied over the fields from the Form called “MS Office Document\New Word Document” in this template into my form in my database, not changing a thing. I copied a few from the Subform “DocumentWorkflow” also.
The script works fine with the template, however, when I run it in my database, I continually get the error: “Cannot locate field” when it hits a certain point.
Here is my script:
-
'Let’s check to make sure the doc is in Edit Mode…
-
If doc.EditMode = True Then
-
Else
-
doc.EditMode = True
-
End If
-
If note.HasItem(“$OLEObjProgID”) Then
-
sOleField = note.~$OLEObjField(0)
-
If doc.IsNewDoc Then
-
note.~$OLEVersion = “46”
-
doc.RefreshHideFormulas
-
doc.GotoField(sOleField)
-
Set oleobject = doc.CreateObject(“OLEObject”,note.~$OLEObjProgID(0),“”)
-
Call oleobject.Range().InsertFile(LetterFilePath)
-
Else
-
'Let’s exit if the doc is being accessed through the Preview Pane…
-
If doc.InPreviewPane = True Then
-
Exit Sub
-
End If
-
'Let’s check to see if the doc has an embedded object…
-
If note.HasEmbedded = True Then
-
Set rtitem = note.GetFirstItem(sOleField)
-
Set embed = rtitem.EmbeddedObjects(0)
-
'Let’s see if this is an older document…
-
If note.~$OLEVersion(0) <> “46” Then
-
Set oleobject = embed.Activate(True)
-
Else
-
Set oleobject = doc.GetObject(embed.name)
-
End If
-
Else
-
'Let’s create the Word doc, since there is no embedded object…
-
If doc.EditMode = True Then
-
doc.GotoField(sOleField)
-
'Call doc.CreateObject(“OLEObject”,note.~$OLEObjProgID(0),“”)
-
Set oleobject = doc.CreateObject(“OLEObject”,note.~$OLEObjProgID(0),“”)
-
Call oleobject.Range().InsertFile(LetterFilePath)
-
End If
-
End If
-
End If
-
End If
Line 32 (it is looking for a rich text field called “Body”) is where the error continually occurs. I am opening an existing document - one that already has an embedded object on it.
The doc (UIDoc) is in Edit Mode. I do not have any sections on this form.
The rich text field “Body” does exist on the form and contains the same HideWhen formulas that were in the template.
Thanks!
Dan