【问题标题】:How to show up a window of an application with VBA ? (Lotus Notes)如何使用 VBA 显示应用程序的窗口? (莲花便笺)
【发布时间】:2016-12-05 10:01:18
【问题描述】:

我想在 VBA 代码在 Lotus Notes 中写入邮件时显示 Lotus Notes 窗口。我希望在所有操作期间都显示 Lotus Notes 窗口。

我试过这段代码:

Sub init_mail()
Dim oSess As Object
Dim ntsServer As String
Dim ntsMailFile As String

Set oSess = CreateObject("Notes.NotesSession")    
ntsServer = oSess.GetEnvironmentString("MailServer", True)
ntsMailFile = oSess.GetEnvironmentString("MailFile", True)
Set odb = oSess.GetDatabase(ntsServer, ntsMailFile)
Set Workspace = CreateObject("Notes.NotesUIWorkspace")
Call Workspace.composedocument(, , "Memo")
Set uidoc = Workspace.CURRENTDOCUMENT
uidoc.Document.deliveryreport = "C"
uidoc.Document.Importance = "Haute"
uidoc.Visible = true

我认为 Visible 可以说 Lotus Note 保持开放和可见。 我认为不应以这种方式使用“可见”。我遇到了这个错误:

Execution error '438'
object doesn't support this property or method

【问题讨论】:

  • 如果我的回答合适,您可以将其设置为接受:-)
  • 首先,Visible 属性仅表示您可以看到具有焦点的窗口。它不给窗口焦点。其次,错误信息说的是实话:Lotus Notes 中的 OLE 服务器对象类不支持 Visible 属性。如果该操作通常在 Notes 客户端中可见,那么它将通过 OLE 可见。

标签: vba lotus-notes


【解决方案1】:

祝您事业顺利,Lotus Notes 的 OLE/COM 引擎已经过时了,调试起来非常痛苦。

根据您的代码,我假设您在 LotusScript 方面几乎没有经验,您使用的编程范例在 LotusScript 中不起作用。

一般来说,我建议您首先编写在 Notes 客户端中运行良好的代码,并且仅当它工作时,然后将其移植到 VBA。在这里,集成的帮助文件是您的朋友,它是 IBM 为 Domino/Notes 平台提供体面文档的最后残余之一。您将不得不围绕几个奇怪的概念(在这种特殊情况下,前端和后端文档之间的区别),并处理大量令人抓狂的错误。

下面会做你想做的事。请注意,后端文档在显示在工作区之前会被保存,这是为了能够显示作为邮件正文的富文本字段。

Dim oSess As Object
Set oSess = CreateObject("Notes.NotesSession")
Dim ntsServer As String
ntsServer = oSess.GetEnvironmentString("MailServer", True)
Dim ntsMailFile As String
ntsMailFile = oSess.GetEnvironmentString("MailFile", True)

Dim Maildb As Object
Set Maildb = oSess.GetDatabase(ntsServer, ntsMailFile)
If Not Maildb.IsOpen Then
    Maildb.OPENMAIL
End If

Set MailDoc = Maildb.CREATEDOCUMENT
Call MailDoc.REPLACEITEMVALUE("Form", "Memo")
Call MailDoc.REPLACEITEMVALUE("SendTo", "Joe Example")
Call MailDoc.REPLACEITEMVALUE("Subject", "Subject Text")
Set Body = MailDoc.CREATERICHTEXTITEM("Body")
Call Body.APPENDTEXT("Body text here")
Call Body.ADDNEWLINE(2)
Call MailDoc.Save(True, True)

Set Workspace = CreateObject("Notes.NotesUIWorkspace")
Call Workspace.EditDocument(True, MailDoc)

【讨论】:

  • 你好@Andrew Magerman,描述我的问题很复杂。无论如何,我一直在寻找的答案是几句话:AppActivate“Lotus Notes”:D
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-07-04
  • 1970-01-01
相关资源
最近更新 更多