.FINDSTRING Lotus Notes VBA

所以我使用Excel为我做了一些例程,并发送一封电子邮件,每一个哀悼日常从SAP提取的数据。 这些数据包括应对2个图像和图表。

问题是,当我没有logging笔记,macros运行顺利,但是当它已经打开,“.FINDSTRING”找不到我已经插入特定的文本来粘贴图像。

我不知道为什么,我猜我需要一个命令来select莲花,并把它变为活动,所以findtring可以工作,但我不知道该怎么办。

这是一个编码:

'________________________________________________________________________ Windows(FileHoje).Activate Columns("A:N").Select Range("A2").Activate Selection.ColumnWidth = 10 Columns("G:G").Select Selection.ColumnWidth = 2.14 Columns("C:C").EntireColumn.AutoFit Columns("K:K").EntireColumn.AutoFit '________________________________________________________________________ Selection.CopyPicture Appearance:=xlScreen, Format:=xlPicture Set NUIdoc = NUIWorkSpace.EDITDocument(True, NDoc) With NUIdoc .GotoField ("Body") .FINDSTRING "**1**" Windows(wb).Activate Sheets("Indicadores").Select ' ActiveSheet.PivotTables("Tabela dinâmica1").PivotFields("Semana").CurrentPage = Range("AV23").Value ActiveSheet.Shapes("Grupo 3").Select ActiveWindow.WindowState = xlNormal ActiveWindow.WindowState = xlMaximized Selection.Copy .Paste Application.CutCopyMode = False '________________________________________________________________________ .GotoField ("Body") .FINDSTRING "**2**" Windows(FileHoje).Activate Dim LR As Integer LR = Range("H" & Rows.Count).End(xlUp).row Range("H1:N" & LR).Select Selection.CopyPicture Appearance:=xlScreen, Format:=xlPicture .Paste Application.CutCopyMode = False '________________________________________________________________________ .GotoField ("Body") .FINDSTRING "**3**" Windows(FileHoje).Activate Dim LW As Integer LW = Range("A" & Rows.Count).End(xlUp).row Range("A1:F" & LW).Select Selection.CopyPicture Appearance:=xlScreen, Format:=xlPicture .Paste Application.CutCopyMode = False '________________________________________________________________________ Windows(FileHoje).Activate Range("A9").Select Range("A2:N60000").Select Selection.Interior.ColorIndex = 2 Range("O1").Select Range(Selection, Selection.End(xlToRight)).Select Range(Selection, Selection.End(xlDown)).Select Selection.Interior.ColorIndex = 15 Range("A2").Select Workbooks(FileHoje).Close SaveChanges:=True '________________________________________________________________________ If attachmentFile <> "" Then If Dir(attachmentFile) <> "" Then Set Attachment = .Document.CreateRichTextItem("Attachment") .InsertText String(2, vbLf) & "File attached: " & Mid(attachmentFile, InStrRev(attachmentFile, "\") + 1) Attachment.EmbedObject EMBED_ATTACHMENT, "", attachmentFile Else MsgBox "Arquivo" & attachmentFile & " Não encontrado, não foi adicionado em anexo." End If End If '________________________________________________________________________ .Send .Close End With Set NSession = Nothing Kill attachmentFile Application.DisplayAlerts = True Application.ScreenUpdating = True End Sub 

这里的问题:如果Notes-客户端已经打开,那么使用“EditDocument”不会改变窗口焦点到Notes-客户端。 你必须自己做这个。

在我的一个项目中,我是这样做的:

 Set objWshShell = CreateObject("WScript.Shell") objWshShell.AppActivate "Lotus Notes" objWshShell.AppActivate "IBM Lotus Notes" objWshShell.AppActivate "IBM Lotus Notes " objWshShell.AppActivate "IBM Notes " 

AppActivate匹配打开的应用程序的标题与给定的string,如果没有匹配的应用程序,那么它什么都不做…