"Cannot Locate Field" using uidoc.GotoField

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:

  1. 'Let’s check to make sure the doc is in Edit Mode…

  2. If doc.EditMode = True Then

  3. Else

  4. doc.EditMode = True

  5. End If

  6. If note.HasItem(“$OLEObjProgID”) Then

  7. sOleField = note.~$OLEObjField(0)

  8. If doc.IsNewDoc Then

  9. note.~$OLEVersion = “46”

  10. doc.RefreshHideFormulas

  11. doc.GotoField(sOleField)

  12. Set oleobject = doc.CreateObject(“OLEObject”,note.~$OLEObjProgID(0),“”)

  13. Call oleobject.Range().InsertFile(LetterFilePath)

  14. Else

  15. 'Let’s exit if the doc is being accessed through the Preview Pane…

  16. If doc.InPreviewPane = True Then

  17. Exit Sub

  18. End If

  19. 'Let’s check to see if the doc has an embedded object…

  20. If note.HasEmbedded = True Then

  21. Set rtitem = note.GetFirstItem(sOleField)

  22. Set embed = rtitem.EmbeddedObjects(0)

  23. 'Let’s see if this is an older document…

  24. If note.~$OLEVersion(0) <> “46” Then

  25. Set oleobject = embed.Activate(True)

  26. Else

  27. Set oleobject = doc.GetObject(embed.name)

  28. End If

  29. Else

  30. 'Let’s create the Word doc, since there is no embedded object…

  31. If doc.EditMode = True Then

  32. doc.GotoField(sOleField)

  33. 'Call doc.CreateObject(“OLEObject”,note.~$OLEObjProgID(0),“”)

  34. Set oleobject = doc.CreateObject(“OLEObject”,note.~$OLEObjProgID(0),“”)

  35. Call oleobject.Range().InsertFile(LetterFilePath)

  36. End If

  37. End If

  38. End If

  39. 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

Subject: “Cannot Locate Field” using uidoc.GotoField

I haven’t read the code, but the clue may be with the hide-when formulae. Rich text fields that are:

  • hidden (remember rich text fields can be hidden independently of what the design hide-when formulae are)

  • in collapsed sections

  • in tabbed tables without focus

… can all give this ui doc error.

HTH

Subject: RE: “Cannot Locate Field” using uidoc.GotoField

The fields are copied from Lotus’ Microsoft Office Library Template.

It works fine in the template, I haven’t changed anything, so why doesn’t it work in my database?

Thanks for the help!!!

Subject: RE: “Cannot Locate Field” using uidoc.GotoField

Hmm. I’d still look to check there’s no weird hide-when code or whatever on the field in question. The formula may be driven from another field that you don’t have. Or the field may have an event (e.g. Entering) that’s causing problems with any UI calls.

Subject: What I have found out…

The field has the following Hide When checked:Previewed for Reading

Previewed for Editing

Copied to the Clipboard

I removed all the checkmarks and it worked.

I would like to continue to use this Hide When.

I will see if there is any other formula…