Ayuda macro error con With - End With
Buena día a todos
Expertos, solicitando su apoyo con el siguiente código que envía una imagen dentro del cuerpor de un mail de Lotus Notes, el problema es que me marca un error en la siguiente linea "GOtofield ("Body")" que menciona "Error 91 en tiempo de ejecución Variable de objeto o bloque With no establecido", según yo esta todo declarado y los with tiene entrada y cierre.
Sub Lotus_VDS()
Dim NSession As Object
Dim NDatabase As Object
Dim NUIWorkSpace As Object
Dim NDoc As Object
Dim NUIdoc As Object
Dim WordApp As Object
Dim Subject As String
Dim HOY As Date
HOY = Hoja3.Range("D4").Value
Subject = "Ventanas de Servicio " & HOY
Debug.Print Subject
Set NSession = CreateObject("Notes.NotesSession")
Set NUIWorkSpace = CreateObject("Notes.NotesUIWorkspace")
Set NDatabase = NSession.GetDatabase("", "")
If Not NDatabase.IsOpen Then NDatabase.OPENMAIL
'Create a new Lotus Notes document
Set NDoc = NDatabase.CreateDocument
With NDoc
.SendTo = "[email protected]" 'CHANGE RECIPIENT EMAIL ADDRESS
.CopyTo = ""
.Subject = Subject
'Email body text, including marker text which will be replaced by the Excel cells
.Body = "Text in email body" & vbLf & vbLf & _
"B1:H42" & vbLf & vbLf & _
"Excel cells are shown above"
.Sabe True, False
End With
'Edit the just-created document to copy and paste the Excel cells into it via Word
Set NUIdoc = NUIWorkSpace.EDITDocument(True, NDoc)
With NUIdoc
'Find the marker text in the Body item
.GOtofield ("Body")
.FINDSTRING "B1:H42"
'.DESELECTALL 'Uncomment to leave the marker text in place (cells are inserted immediately before)
'Copy Excel cells to clipboard
Sheets("Detalle").Range("B1:H42").Copy 'CHANGE SHEET AND RANGE TO BE COPIED AND PASTED
'Create a temporary Word Document
Set WordApp = CreateObject("Word.Application")
WordApp.Visible = False 'True to aid debugging
WordApp.Documents.Add
'Paste into Word document and copy to clipboard
With WordApp.Selection
.PasteSpecial DataType:=4 'Enum WdPasteDataType: 10 = HTML; 2 = Text; 1 = RTF
.WholeStory
.Copy
End With
'Paste from clipboard (Word) to Lotus Notes document
.Paste
Application.CutCopyMode = False
WordApp.Quit SaveChanges:=False
Set WordApp = Nothing
.Send
.Close
End With
Set NSession = Nothing
Set WordApp = Nothing
End Sub
Agradeciendo todo su apoyo
Gracias