So I'm using Excel to do some routines for me, and send an Email every mourning with the data the routine has extracted from SAP. This data includes coping 2 images, and a graph.
The problem is, that when I dont have notes logged in, the macro runs smoothly, but when it is already open, the ".FINDSTRING" cannot find the specific text I had inserted to paste the images.
I'm not sure why, I'm guessing I need a command to select the lotus and turn it active so the findstring could work, but I dont know what to do.
Here's a piece of the coding:
I need for this to run without the problem of it not finding the string.
The problem is, that when I dont have notes logged in, the macro runs smoothly, but when it is already open, the ".FINDSTRING" cannot find the specific text I had inserted to paste the images.
I'm not sure why, I'm guessing I need a command to select the lotus and turn it active so the findstring could work, but I dont know what to do.
Here's a piece of the coding:
Code:
'________________________________________________________________________
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
I need for this to run without the problem of it not finding the string.