2016-09-15 24 views
1

私は私のためにいくつかのルーチンを実行するためにExcelを使用しており、ルーチンがSAPから抽出したデータを使用してメールを送信します。このデータには、対処する2つの画像とグラフが含まれます。.FINDSTRING Lotus Notes VBA

問題は、メモが記録されていないと、マクロがスムーズに実行されますが、既に開いているときに ".FINDSTRING"が画像を貼り付けるために挿入した特定のテキストを見つけることができません。

なぜ、私は蓮を選択し、それをアクティブにするコマンドが必要だと思うのか分かりませんが、findstringは機能するかもしれませんが、私は何をすべきか分かりません。ここで

は、コードの一部です:ここ

'________________________________________________________________________ 
    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 
+0

待機しているので、Notesを閉じた状態で、Set NUIdoc = NUIWorkSpace.EditDocument()はNotes文書を編集モードにしますか?それは私には奇妙に思える。 – Duston

+0

これはVBAなので、NotesUIWorkspaceクラスを使用しているので、COMクラス(lotus。*)ではなくOLEクラス(注。*)を使用している必要があります。 OLEクラスは、まだ実行されていない場合にクライアントを起動します。 –

+0

.GotoField( "Body")の最初の呼び出しの後にすべてをコメントアウトするとどうなりますか?ノーツクライアントウィンドウはフォーカスを取得し、カーソルは本文フィールドの先頭に配置されますか? –

答えて

1

問題:Notes- Clientがすでにオープンしている場合は、「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のは、それは単に何もしない、与えられた文字列で開いているアプリケーションのタイトルと一致する...

関連する問題