Can't use CreateObject in Profile Document?

I have a button with some Lotus Script that, when pressed, uses CreateObject to put a picture into a Rich text field. This works in a regular form, but fails on a profile document with the error “Document command not available”. The line that is causing this is: Call uidoc.CreateObject(“”,“”,filenames)

Why is this occuring? Is there a way around this on a profile document?

Thank you for any help. The full code follows:

Sub Click(Source As Button)

Dim ws As New NotesUIWorkspace

Dim uidoc As Notesuidocument

Dim filenames

Dim path

Set uidoc = ws.CurrentDocument

REM Get filename from user

filenames = ws.OpenFileDialog(False, "Select picture","BMP|*.bmp|TIFF|*.tif","c:\")



Call uidoc.GotoField( "Attachments" )

Call uidoc.CreateObject("","",filenames)

End Sub

Subject: Can’t use CreateObject in Profile Document?

Is there already another attachment in the profile document? If so, your problem might be related to this post:

http://www-10.lotus.com/ldd/46dom.nsf/55c38d716d632d9b8525689b005ba1c0/51e1b311ff2bff5a85256f8100255762?OpenDocument

This guy was trying to access those file attachments through LS, not attach them but the problems may be related.

Hope that helps.

Subject: RE: Can’t use CreateObject in Profile Document?

No, there is no other attachment. The error pops up on the first try.

Subject: RE: Can’t use CreateObject in Profile Document?

Hmmmm. Then this might fall under another one of those quirky things that don’t work for profile documents. As an alternative, could you replace your LS code with:

@Command([EditGotoField]; “Attachments”);

@Command([EditInsertFileAttachment])

Not as elegant but it’ll work.

Hope that helps.