RodrigoFinguer
Board Regular
- Joined
- Jun 13, 2017
- Messages
- 75
Hello!!
I am really having trouble with this issue here.
This is my code:
My code go to the SAP, opens the attachments list and double click the file to open from SAP. Then I get the file and move from "C:\Temp" to "myfolder", whatever folder is this.
The thing is that, when there is "xlsx" files to open from SAP, the workbook does not open unless I stop the macro or debug, this way I can't move the file from the Temp folder.
PS: I don't know how to make the code colorful to make easy to read.
I am really having trouble with this issue here.
This is my code:
Code:
Sub sap_attachment_2()
'anexos na lista de anexos
Set SapGuiAuto = GetObject("SAPGUI")
Set SAPApplication = SapGuiAuto.GetScriptingEngine
Set SAPConnection = SAPApplication.Children(0)
Set session = SAPConnection.Children(0)
Application.EnableEvents = False
session.findById("wnd[0]").maximize
session.findById("wnd[0]/titl/shellcont/shell").pressContextButton "%GOS_TOOLBOX"
session.findById("wnd[0]/titl/shellcont/shell").selectContextMenuItem "%GOS_VIEW_ATTA"
Set SAPattachs = session.findById("wnd[1]/usr/cntlGRID1/shellcont/shell")
session.findById("wnd[1]/usr/cntlGRID1/shellcont/shell").setCurrentCell 0, "BITM_DESCR"
count_files = SAPattachs.RowCount
Application.ScreenUpdating = True
For q = 2 To count_files - 1
Name = session.findById("wnd[1]/usr/cntlGRID1/shellcont/shell").getcellvalue(q, "BITM_DESCR")
session.findById("wnd[0]").maximize
session.findById("wnd[1]/usr/cntlGRID1/shellcont/shell").setCurrentCell q, "BITM_DESCR"
session.findById("wnd[1]/usr/cntlGRID1/shellcont/shell").selectedRows = q
session.findById("wnd[1]/usr/cntlGRID1/shellcont/shell").doubleClickCurrentCell
Application.Wait (Now + TimeValue("0:00:02"))
'Application.OnTime Now + TimeSerial(0, 0, 4), "Módulo4.movePDF"
movePDF
If hwnd <> 0 Then
closepdf
Else
End If
Next
End Sub
My code go to the SAP, opens the attachments list and double click the file to open from SAP. Then I get the file and move from "C:\Temp" to "myfolder", whatever folder is this.
The thing is that, when there is "xlsx" files to open from SAP, the workbook does not open unless I stop the macro or debug, this way I can't move the file from the Temp folder.
PS: I don't know how to make the code colorful to make easy to read.