Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/fsharp/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Excel 运行时错误13-尝试编辑Lotus Notes的richtext项时类型不匹配_Excel_Vba_Lotus_Richtext - Fatal编程技术网

Excel 运行时错误13-尝试编辑Lotus Notes的richtext项时类型不匹配

Excel 运行时错误13-尝试编辑Lotus Notes的richtext项时类型不匹配,excel,vba,lotus,richtext,Excel,Vba,Lotus,Richtext,我正在尝试通过VBA编辑现有notes文档,然后自动发送它 我已经创建了几乎所有的东西——只需要弄清楚如何在richtext元素中的某个位置添加特定的文本 Sub sendMail() 'inputIndID As String, inputRecipient As String, inputIncDescription As String) Dim mailDB As Object Dim mailToSend As Object Dim body As Object Dim session

我正在尝试通过VBA编辑现有notes文档,然后自动发送它

我已经创建了几乎所有的东西——只需要弄清楚如何在richtext元素中的某个位置添加特定的文本

Sub sendMail() 'inputIndID As String, inputRecipient As String, inputIncDescription As String)

Dim mailDB As Object
Dim mailToSend As Object
Dim body As Object
Dim session As Object
Dim view As Object
Dim entries As Object
Dim docIDs() As String
Dim docSubjects() As String
Dim incID, incDescription As String
Dim element As String
Dim bodyNavigator As Object

incID = "<INC-ID>"
incDescription = "<INC-Betreff>"

'Start a session to notes
Set session = CreateObject("Notes.NotesSession")
'This line prompts for password of current ID noted in Notes.INI
'Call Session.Initialize
'or use below to supply password of the current ID

'Open the mail database in notes
Set mailDB = session.GetDatabase("Eschen10/Presta", "mail\qcpcsupport.nsf")
If mailDB.IsOpen = False Then
    Call mailDB.Open
End If

'Search for all the messages in the folder "Umfrage"
Set view = mailDB.GetView("Umfrage")
Set entries = view.AllEntries
If entries.Count = 0 Then
    MsgBox "Keine Nachricht im Umfrage Ordner."
End If
ReDim docIDs(entries.Count - 1)
ReDim docSubjects(entries.Count - 1)
Set entry = entries.GetFirstEntry
Do Until entry Is Nothing
    docIDs(i) = entry.NoteID
    docSubjects(i) = entry.Document.GetItemValue("Subject")(0) 'based on standard R5 mail template column order
    'If the documents title matches the searched one it will be taken and worked with later
    If docSubjects(i) = "Umfrage PC-Support Servicequalität" Then
        Set mailToSend = entry.Document
    End If
    i = i + 1
    Set entry = entries.GetNextEntry(entry)
Loop


'Set the recipient
Call mailToSend.ReplaceItemValue("SendTo", "simon.hartmann@thyssenkrupp.com")

'Get and change the body content
Set body = mailToSend.GetFirstItem("Body")
Set bodyNavigator = body.CreateNavigator()

'Replace markers with correct text

element = "<"

If (body.Type = RICHTEXT) Then
    Call bodyNavigator.FindFirstString(element)
    Call body.BeginInsert(bodyNavigator, True)
    Call body.AppendText("123456")
    Call bodyNavigator.FindNextString(element)
    Call body.BeginInsert(bodyNavigator, True)
    Call body.AppendText("Antrag Guest WLAN")
End If


'Example to save the message (optional)
mailToSend.SaveMessageOnSend = True

'Send the document
'Gets the mail to appear in the Sent items folder
mailToSend.Save True, False
Call mailToSend.ReplaceItemValue("PostedDate", Now())
Call mailToSend.Send(False)

'changes the body back and saves the document in the folder "Umfrage" so it can be resent next time
Call mailToSend.PutInFolder("Umfrage")

'Clean Up
Set mailDB = Nothing
Set mailToSend = Nothing
Set body = Nothing
Set session = Nothing


End Sub
我得到了错误-运行时错误13-类型不匹配

我还尝试为所有变量提供LotusNotes的正确数据类型,但是这些变量中的每一个都有问题

有没有办法“强制”bodynavigator为正确类型?或者我的错误在哪里?我是不是少了一个图书馆或者别的什么

提前感谢

问候,, 西蒙,你读了那本书了吗

您可以在此处找到以下信息:

参数
目标$

绳子。搜索字符串

选择权$

长。以下任何一项。通过将多个选项与加法或逻辑or组合来指定多个选项

  • RT_FIND_accentsensitive(4)(默认为重音敏感)
  • RT_FIND_不区分大小写(1)(默认值区分大小写)
  • RT_FIND_PITCHINSENSITIVE(2)(默认为不区分基音)

所以:您的第二个参数“true”是错误的类型。。。因此,类型不匹配…

欢迎使用SO。如何定义body.BeginInsert的参数?您是否看到notesRichTextRange.FindAndReplace()daamn。。但在对该项的描述中,我发现了以下内容:Syntax Call notesRichTextItem.BeginInsert(element,[after])after应该是true或false。。。无论如何,谢谢!您知道我如何最容易地在正确的位置添加文本、发送项目、再次删除文本并将其保存在文件夹中吗?提前谢谢!我通常创建一个新的邮件文档,在其中我根据需要添加文本,并在不修改原始文本的情况下发送该文档。如果你真的想修改原稿:只需设置doc.SaveMessageOnSend=False,发送邮件,而不要调用“doc.Save”。。。。
Call body.BeginInsert(bodyNavigator, True)