运行时错误 13 - 尝试编辑 Lotus Notes 的富文本项时键入不匹配

西蒙·哈特曼

我正在尝试通过 VBA 编辑现有的笔记文档,然后自动发送。

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

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", "[email protected]")

'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

目前我在以下行失败:

Call body.BeginInsert(bodyNavigator, True)

我收到错误 - 运行时错误 13 - 类型不匹配

我也已经尝试为所有变量提供 Lotus Notes 的正确数据类型 - 但随后我对每个变量都有问题。

有没有办法可以“强制” bodynavigator 为正确类型?或者我的错误在哪里?我错过了图书馆还是什么?

提前致谢!!!

问候, 西蒙

托斯滕链接

您是否阅读了NotesRichtextNavigator文档

您可以在那里找到以下信息:

参数
目标$

细绳。搜索字符串。

选项$

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

  • RT_FIND_ACCENTINSENSITIVE (4)(默认为重音敏感)
  • RT_FIND_CASEINSENSITIVE (1)(默认区分大小写)
  • RT_FIND_PITCHINSENSITIVE (2)(默认是音高不敏感)

所以:你的第二个参数“true”只是错误的类型......因此类型不匹配......

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

运行时错误13:尝试从另一个工作簿中调用函数时,在VBA中键入不匹配

得到运行时错误“ 13”:运行以下宏时键入不匹配

运行时错误13:每次我运行代码时都键入不匹配

尝试检测是否关闭了用户窗体时在Excel VBA中得到“运行时错误'13':类型不匹配”

尝试检查单元格是否包含整数时出现运行时错误 13 类型不匹配

尝试以编程方式创建用户窗体按钮时,运行时“ 13”错误类型不匹配

运行时错误'13':清除单元格内容时键入不匹配

运行时错误'13:比较日期时键入不匹配-EXCEL VBA

运行时错误“13”:宏中的类型不匹配

Excel VBA运行时错误类型不匹配13

Excel VBA运行时错误“ 13”:类型不匹配

运行时错误'13':类型不匹配,定义了PivotCahe

运行时错误13,类型不匹配MsgBox取消

运行时错误“13”类型不匹配:如果或

类型不匹配运行时错误13

运行时错误13 /类型不匹配

运行时错误 13' 类型不匹配 VBA excel

工作表运行时错误“13”:类型不匹配

CLng具有文本字符串时,运行时错误13不匹配

运行时错误13在workbook.worksheets中键入不匹配

运行时错误 13:使用 DateSerial 在日期上键入不匹配

使用Trim时出现运行时错误13

运行时错误“13”:显示来自 JSON 数组的数据时出现类型不匹配错误

尝试编辑/更新时出现DBContext错误

运行时错误13输入不匹配〜当Application.Inputbox取消时

工作的DLL代码失败,并出现运行时错误13:调试时类型不匹配

打开工作簿时如何解决“运行时错误” 13'类型不匹配

运行时错误 13

运行时错误 13 之前成功运行的程序模块中的类型不匹配