Sub testthu()
Dim i As Long, EndR As Long
If Not IsObject(Application) Then
Set SapGuiAuto = GetObject("SAPGUI")
Set Applications = SapGuiAuto.GetScriptingEngine
End If
If Not IsObject(Connection) Then
Set Connection = Applications.Children(0)
End If
If Not IsObject(session) Then
Set session = Connection.Children(0)
End If
If IsObject(WScript) Then
WScript.ConnectObject session, "on"
WScript.ConnectObject Application, "on"
End If
EndR = Sheet1.Range("A65000").End(xlUp).Row
session.findById("wnd[0]").maximize
session.findById("wnd[0]/usr/cntlIMAGE_CONTAINER/shellcont/shell/shellcont[0]/shell").doubleClickNode "0000000259"
For i = 2 To EndR
session.findById("wnd[0]/usr/tabsHSMG/tabpHSMG_FC1/ssubHSMG_SCA:ZPG_MG_HS:0201/ctxtZTB_HSMG_H-ZF_MST").Text = Sheet1.Range("A" & i).Value
session.findById("wnd[0]/usr/tabsHSMG/tabpHSMG_FC1/ssubHSMG_SCA:ZPG_MG_HS:0201/txtZTB_HSMG_H-SO_HS").Text = Sheet1.Range("B" & i).Value
session.findById("wnd[0]/usr/tabsHSMG/tabpHSMG_FC1/ssubHSMG_SCA:ZPG_MG_HS:0201/ctxtZTB_HSMG_H-NGAY_HS").Text = "05052020"
session.findById("wnd[0]/usr/tabsHSMG/tabpHSMG_FC1/ssubHSMG_SCA:ZPG_MG_HS:0201/txtZTB_HSMG_H-SO_CVAN").Text = "01"
session.findById("wnd[0]/usr/tabsHSMG/tabpHSMG_FC1/ssubHSMG_SCA:ZPG_MG_HS:0201/ctxtZTB_HSMG_H-NGAY_CVAN").Text = "05052020"
session.findById("wnd[0]/usr/tabsHSMG/tabpHSMG_FC1/ssubHSMG_SCA:ZPG_MG_HS:0201/ctxtZTB_HSMG_H-NGAY_DU_HS").Text = "05052020"
session.findById("wnd[0]/usr/tabsHSMG/tabpHSMG_FC1/ssubHSMG_SCA:ZPG_MG_HS:0201/ctxtZTB_HSMG_H-TRG_HOP_MG").Text = "20"
session.findById("wnd[0]/usr/tabsHSMG/tabpHSMG_FC1/ssubHSMG_SCA:ZPG_MG_HS:0201/ctxtZTB_HSMG_H-TRG_HOP_MG").SetFocus
session.findById("wnd[0]/usr/tabsHSMG/tabpHSMG_FC1/ssubHSMG_SCA:ZPG_MG_HS:0201/ctxtZTB_HSMG_H-TRG_HOP_MG").caretPosition = 2
session.findById("wnd[0]/usr/tabsHSMG/tabpHSMG_FC1/ssubHSMG_SCA:ZPG_MG_HS:0201/cntlDNMG/shellcont/shell").pressToolbarButton "CREATE"
session.findById("wnd[0]/usr/tabsHSMG/tabpHSMG_FC1/ssubHSMG_SCA:ZPG_MG_HS:0201/cntlDNMG/shellcont/shell").pressToolbarButton "CREATE"
session.findById("wnd[0]/usr/tabsHSMG/tabpHSMG_FC1/ssubHSMG_SCA:ZPG_MG_HS:0201/cntlDNMG/shellcont/shell").modifyCell 0, "ZF_TIEU_MUC", "1701"
session.findById("wnd[0]/usr/tabsHSMG/tabpHSMG_FC1/ssubHSMG_SCA:ZPG_MG_HS:0201/cntlDNMG/shellcont/shell").modifyCell 0, "ZF_CHUONG", "757"
session.findById("wnd[0]/usr/tabsHSMG/tabpHSMG_FC1/ssubHSMG_SCA:ZPG_MG_HS:0201/cntlDNMG/shellcont/shell").modifyCell 0, "ZF_KY_THUE_TU", "2005"
session.findById("wnd[0]/usr/tabsHSMG/tabpHSMG_FC1/ssubHSMG_SCA:ZPG_MG_HS:0201/cntlDNMG/shellcont/shell").modifyCell 0, "ZF_KY_THUE_DEN", "2005"
session.findById("wnd[0]/usr/tabsHSMG/tabpHSMG_FC1/ssubHSMG_SCA:ZPG_MG_HS:0201/cntlDNMG/shellcont/shell").modifyCell 0, "ZF_THUE_DNMG", Sheet1.Range("I" & i).Value
session.findById("wnd[0]/usr/tabsHSMG/tabpHSMG_FC1/ssubHSMG_SCA:ZPG_MG_HS:0201/cntlDNMG/shellcont/shell").modifyCell 0, "ZF_MA_LYDO", "2001"
session.findById("wnd[0]/usr/tabsHSMG/tabpHSMG_FC1/ssubHSMG_SCA:ZPG_MG_HS:0201/cntlDNMG/shellcont/shell").modifyCell 1, "ZF_TIEU_MUC", "1003"
session.findById("wnd[0]/usr/tabsHSMG/tabpHSMG_FC1/ssubHSMG_SCA:ZPG_MG_HS:0201/cntlDNMG/shellcont/shell").modifyCell 1, "ZF_CHUONG", "757"
session.findById("wnd[0]/usr/tabsHSMG/tabpHSMG_FC1/ssubHSMG_SCA:ZPG_MG_HS:0201/cntlDNMG/shellcont/shell").modifyCell 1, "ZF_KY_THUE_TU", "2005"
session.findById("wnd[0]/usr/tabsHSMG/tabpHSMG_FC1/ssubHSMG_SCA:ZPG_MG_HS:0201/cntlDNMG/shellcont/shell").modifyCell 1, "ZF_KY_THUE_DEN", "2005"
session.findById("wnd[0]/usr/tabsHSMG/tabpHSMG_FC1/ssubHSMG_SCA:ZPG_MG_HS:0201/cntlDNMG/shellcont/shell").modifyCell 1, "ZF_THUE_DNMG", Sheet1.Range("K" & i).Value
session.findById("wnd[0]/usr/tabsHSMG/tabpHSMG_FC1/ssubHSMG_SCA:ZPG_MG_HS:0201/cntlDNMG/shellcont/shell").modifyCell 1, "ZF_MA_LYDO", "2001"
session.findById("wnd[0]/usr/tabsHSMG/tabpHSMG_FC1/ssubHSMG_SCA:ZPG_MG_HS:0201/cntlDNMG/shellcont/shell").setCurrentCell 1, "ZF_MA_LYDO"
session.findById("wnd[0]/usr/tabsHSMG/tabpHSMG_FC1/ssubHSMG_SCA:ZPG_MG_HS:0201/cntlDNMG/shellcont/shell").pressEnter
session.findById("wnd[0]/usr/tabsHSMG/tabpHSMG_FC3").Select
session.findById("wnd[0]/usr/tabsHSMG/tabpHSMG_FC3/ssubHSMG_SCA:ZPG_MG_HS:0203/txtZTB_HSMG_H-ZZ_SO_QD").Text = Sheet1.Range("P" & i).Value
session.findById("wnd[0]/usr/tabsHSMG/tabpHSMG_FC3/ssubHSMG_SCA:ZPG_MG_HS:0203/ctxtZTB_HSMG_H-ZZ_NGAY_QD").Text = "06052020"
session.findById("wnd[0]/usr/tabsHSMG/tabpHSMG_FC3/ssubHSMG_SCA:ZPG_MG_HS:0203/txtZTB_HSMG_H-ZZ_SO_QD").SetFocus
session.findById("wnd[0]/usr/tabsHSMG/tabpHSMG_FC3/ssubHSMG_SCA:ZPG_MG_HS:0203/txtZTB_HSMG_H-ZZ_SO_QD").caretPosition = 4
session.findById("wnd[0]/usr/tabsHSMG/tabpHSMG_FC3/ssubHSMG_SCA:ZPG_MG_HS:0203/btnBTN_HOTRO").press
session.findById("wnd[0]/usr/tabsHSMG/tabpHSMG_FC3/ssubHSMG_SCA:ZPG_MG_HS:0203/cntlDXMG/shellcont/shell").modifyCell 0, "ZF_THUE_DU_DKMG", Sheet1.Range("N" & i).Value
session.findById("wnd[0]/usr/tabsHSMG/tabpHSMG_FC3/ssubHSMG_SCA:ZPG_MG_HS:0203/cntlDXMG/shellcont/shell").modifyCell 1, "ZF_THUE_DU_DKMG", Sheet1.Range("O" & i).Value
session.findById("wnd[0]/usr/tabsHSMG/tabpHSMG_FC3/ssubHSMG_SCA:ZPG_MG_HS:0203/cntlDXMG/shellcont/shell").pressEnter
session.findById("wnd[0]/tbar[0]/btn[11]").press
session.findById("wnd[0]/tbar[1]/btn[48]").press
session.findById("wnd[0]/tbar[1]/btn[8]").press
Next i
End Sub
Dim i As Long, EndR As Long
If Not IsObject(Application) Then
Set SapGuiAuto = GetObject("SAPGUI")
Set Applications = SapGuiAuto.GetScriptingEngine
End If
If Not IsObject(Connection) Then
Set Connection = Applications.Children(0)
End If
If Not IsObject(session) Then
Set session = Connection.Children(0)
End If
If IsObject(WScript) Then
WScript.ConnectObject session, "on"
WScript.ConnectObject Application, "on"
End If
EndR = Sheet1.Range("A65000").End(xlUp).Row
session.findById("wnd[0]").maximize
session.findById("wnd[0]/usr/cntlIMAGE_CONTAINER/shellcont/shell/shellcont[0]/shell").doubleClickNode "0000000259"
For i = 2 To EndR
session.findById("wnd[0]/usr/tabsHSMG/tabpHSMG_FC1/ssubHSMG_SCA:ZPG_MG_HS:0201/ctxtZTB_HSMG_H-ZF_MST").Text = Sheet1.Range("A" & i).Value
session.findById("wnd[0]/usr/tabsHSMG/tabpHSMG_FC1/ssubHSMG_SCA:ZPG_MG_HS:0201/txtZTB_HSMG_H-SO_HS").Text = Sheet1.Range("B" & i).Value
session.findById("wnd[0]/usr/tabsHSMG/tabpHSMG_FC1/ssubHSMG_SCA:ZPG_MG_HS:0201/ctxtZTB_HSMG_H-NGAY_HS").Text = "05052020"
session.findById("wnd[0]/usr/tabsHSMG/tabpHSMG_FC1/ssubHSMG_SCA:ZPG_MG_HS:0201/txtZTB_HSMG_H-SO_CVAN").Text = "01"
session.findById("wnd[0]/usr/tabsHSMG/tabpHSMG_FC1/ssubHSMG_SCA:ZPG_MG_HS:0201/ctxtZTB_HSMG_H-NGAY_CVAN").Text = "05052020"
session.findById("wnd[0]/usr/tabsHSMG/tabpHSMG_FC1/ssubHSMG_SCA:ZPG_MG_HS:0201/ctxtZTB_HSMG_H-NGAY_DU_HS").Text = "05052020"
session.findById("wnd[0]/usr/tabsHSMG/tabpHSMG_FC1/ssubHSMG_SCA:ZPG_MG_HS:0201/ctxtZTB_HSMG_H-TRG_HOP_MG").Text = "20"
session.findById("wnd[0]/usr/tabsHSMG/tabpHSMG_FC1/ssubHSMG_SCA:ZPG_MG_HS:0201/ctxtZTB_HSMG_H-TRG_HOP_MG").SetFocus
session.findById("wnd[0]/usr/tabsHSMG/tabpHSMG_FC1/ssubHSMG_SCA:ZPG_MG_HS:0201/ctxtZTB_HSMG_H-TRG_HOP_MG").caretPosition = 2
session.findById("wnd[0]/usr/tabsHSMG/tabpHSMG_FC1/ssubHSMG_SCA:ZPG_MG_HS:0201/cntlDNMG/shellcont/shell").pressToolbarButton "CREATE"
session.findById("wnd[0]/usr/tabsHSMG/tabpHSMG_FC1/ssubHSMG_SCA:ZPG_MG_HS:0201/cntlDNMG/shellcont/shell").pressToolbarButton "CREATE"
session.findById("wnd[0]/usr/tabsHSMG/tabpHSMG_FC1/ssubHSMG_SCA:ZPG_MG_HS:0201/cntlDNMG/shellcont/shell").modifyCell 0, "ZF_TIEU_MUC", "1701"
session.findById("wnd[0]/usr/tabsHSMG/tabpHSMG_FC1/ssubHSMG_SCA:ZPG_MG_HS:0201/cntlDNMG/shellcont/shell").modifyCell 0, "ZF_CHUONG", "757"
session.findById("wnd[0]/usr/tabsHSMG/tabpHSMG_FC1/ssubHSMG_SCA:ZPG_MG_HS:0201/cntlDNMG/shellcont/shell").modifyCell 0, "ZF_KY_THUE_TU", "2005"
session.findById("wnd[0]/usr/tabsHSMG/tabpHSMG_FC1/ssubHSMG_SCA:ZPG_MG_HS:0201/cntlDNMG/shellcont/shell").modifyCell 0, "ZF_KY_THUE_DEN", "2005"
session.findById("wnd[0]/usr/tabsHSMG/tabpHSMG_FC1/ssubHSMG_SCA:ZPG_MG_HS:0201/cntlDNMG/shellcont/shell").modifyCell 0, "ZF_THUE_DNMG", Sheet1.Range("I" & i).Value
session.findById("wnd[0]/usr/tabsHSMG/tabpHSMG_FC1/ssubHSMG_SCA:ZPG_MG_HS:0201/cntlDNMG/shellcont/shell").modifyCell 0, "ZF_MA_LYDO", "2001"
session.findById("wnd[0]/usr/tabsHSMG/tabpHSMG_FC1/ssubHSMG_SCA:ZPG_MG_HS:0201/cntlDNMG/shellcont/shell").modifyCell 1, "ZF_TIEU_MUC", "1003"
session.findById("wnd[0]/usr/tabsHSMG/tabpHSMG_FC1/ssubHSMG_SCA:ZPG_MG_HS:0201/cntlDNMG/shellcont/shell").modifyCell 1, "ZF_CHUONG", "757"
session.findById("wnd[0]/usr/tabsHSMG/tabpHSMG_FC1/ssubHSMG_SCA:ZPG_MG_HS:0201/cntlDNMG/shellcont/shell").modifyCell 1, "ZF_KY_THUE_TU", "2005"
session.findById("wnd[0]/usr/tabsHSMG/tabpHSMG_FC1/ssubHSMG_SCA:ZPG_MG_HS:0201/cntlDNMG/shellcont/shell").modifyCell 1, "ZF_KY_THUE_DEN", "2005"
session.findById("wnd[0]/usr/tabsHSMG/tabpHSMG_FC1/ssubHSMG_SCA:ZPG_MG_HS:0201/cntlDNMG/shellcont/shell").modifyCell 1, "ZF_THUE_DNMG", Sheet1.Range("K" & i).Value
session.findById("wnd[0]/usr/tabsHSMG/tabpHSMG_FC1/ssubHSMG_SCA:ZPG_MG_HS:0201/cntlDNMG/shellcont/shell").modifyCell 1, "ZF_MA_LYDO", "2001"
session.findById("wnd[0]/usr/tabsHSMG/tabpHSMG_FC1/ssubHSMG_SCA:ZPG_MG_HS:0201/cntlDNMG/shellcont/shell").setCurrentCell 1, "ZF_MA_LYDO"
session.findById("wnd[0]/usr/tabsHSMG/tabpHSMG_FC1/ssubHSMG_SCA:ZPG_MG_HS:0201/cntlDNMG/shellcont/shell").pressEnter
session.findById("wnd[0]/usr/tabsHSMG/tabpHSMG_FC3").Select
session.findById("wnd[0]/usr/tabsHSMG/tabpHSMG_FC3/ssubHSMG_SCA:ZPG_MG_HS:0203/txtZTB_HSMG_H-ZZ_SO_QD").Text = Sheet1.Range("P" & i).Value
session.findById("wnd[0]/usr/tabsHSMG/tabpHSMG_FC3/ssubHSMG_SCA:ZPG_MG_HS:0203/ctxtZTB_HSMG_H-ZZ_NGAY_QD").Text = "06052020"
session.findById("wnd[0]/usr/tabsHSMG/tabpHSMG_FC3/ssubHSMG_SCA:ZPG_MG_HS:0203/txtZTB_HSMG_H-ZZ_SO_QD").SetFocus
session.findById("wnd[0]/usr/tabsHSMG/tabpHSMG_FC3/ssubHSMG_SCA:ZPG_MG_HS:0203/txtZTB_HSMG_H-ZZ_SO_QD").caretPosition = 4
session.findById("wnd[0]/usr/tabsHSMG/tabpHSMG_FC3/ssubHSMG_SCA:ZPG_MG_HS:0203/btnBTN_HOTRO").press
session.findById("wnd[0]/usr/tabsHSMG/tabpHSMG_FC3/ssubHSMG_SCA:ZPG_MG_HS:0203/cntlDXMG/shellcont/shell").modifyCell 0, "ZF_THUE_DU_DKMG", Sheet1.Range("N" & i).Value
session.findById("wnd[0]/usr/tabsHSMG/tabpHSMG_FC3/ssubHSMG_SCA:ZPG_MG_HS:0203/cntlDXMG/shellcont/shell").modifyCell 1, "ZF_THUE_DU_DKMG", Sheet1.Range("O" & i).Value
session.findById("wnd[0]/usr/tabsHSMG/tabpHSMG_FC3/ssubHSMG_SCA:ZPG_MG_HS:0203/cntlDXMG/shellcont/shell").pressEnter
session.findById("wnd[0]/tbar[0]/btn[11]").press
session.findById("wnd[0]/tbar[1]/btn[48]").press
session.findById("wnd[0]/tbar[1]/btn[8]").press
Next i
End Sub