Hi,
I have been using following VB script in excel to run my macros for a while to update system in AS400. This was working perfectly until I got a new computer.
Basically this scripts copies data from row 1 column 1 and pastes into AS400 screen and continues to row 1 column 2. Afer that it moves to row 2 untill everything in the spreadsheet is complete.
Now, whever I run this script, it will take me to AS400 screen but won't paste anything. Could someone help?
Sub macro1()
Dim yRow
Dim xCol
Dim WindowName
On Error Resume Next
WindowName = Worksheets("Sheet1").Cells(1, 9).Value
Windows(1).WindowState = xlMinimized
AppActivate WindowName, Wait
If Err.Number <> 0 Then
MsgBox Err.Description
Err.Clear
Exit Sub
End If
col = 1
Row = 1
AppActivate WindowName
While Trim(Worksheets("Sheet1").Cells(Row, 1).Value) <> ""
SendKeys CStr(Worksheets("Sheet1").Cells(Row, 1).Value) + "{Enter}" + "{Tab}" + "{Tab}" + "{Tab}"
SendKeys CStr(Worksheets("Sheet1").Cells(Row, 2).Value) + "{Tab}" + "{Tab}" + "{Tab}" + "{Enter}"
Row = Row + 1
Wend
End Sub
I have been using following VB script in excel to run my macros for a while to update system in AS400. This was working perfectly until I got a new computer.
Basically this scripts copies data from row 1 column 1 and pastes into AS400 screen and continues to row 1 column 2. Afer that it moves to row 2 untill everything in the spreadsheet is complete.
Now, whever I run this script, it will take me to AS400 screen but won't paste anything. Could someone help?
Sub macro1()
Dim yRow
Dim xCol
Dim WindowName
On Error Resume Next
WindowName = Worksheets("Sheet1").Cells(1, 9).Value
Windows(1).WindowState = xlMinimized
AppActivate WindowName, Wait
If Err.Number <> 0 Then
MsgBox Err.Description
Err.Clear
Exit Sub
End If
col = 1
Row = 1
AppActivate WindowName
While Trim(Worksheets("Sheet1").Cells(Row, 1).Value) <> ""
SendKeys CStr(Worksheets("Sheet1").Cells(Row, 1).Value) + "{Enter}" + "{Tab}" + "{Tab}" + "{Tab}"
SendKeys CStr(Worksheets("Sheet1").Cells(Row, 2).Value) + "{Tab}" + "{Tab}" + "{Tab}" + "{Enter}"
Row = Row + 1
Wend
End Sub