I am working on SAP Gui Scripting with VBA. I have 200line of information to enter into SAP from excel. However, SAP list hits 23lines max, which you have to than scroll down to enter more lines into the list. Here is my code
i = 0
With session
.findById("wnd[0]").maximize
.findById("wnd[0]/tbar[0]/okcd").Text = "MIGO"
.findById("wnd[0]").sendVKey 0
.findById("wnd[0]/usr/ssubSUB_MAIN_CARRIER:SAPLMIGO:0006/subSUB_HEADER:SAPLMIGO:0101/subSUB_HEADER:SAPLMIGO:0100/tabsTS_GOHEAD/tabpOK_GOHEAD_GENERAL/ssubSUB_TS_GOHEAD_GENERAL:SAPLMIGO:0112/txtGOHEAD-BKTXT").Text = "PKG QTY REF 015835"
While Cells(7 + i, 1).Value <> ""
.findById("wnd[0]/usr/ssubSUB_MAIN_CARRIER:SAPLMIGO:0006/subSUB_ITEMLIST:SAPLMIGO:0200/tblSAPLMIGOTV_GOITEM/ctxtGOITEM-MAKTX[1," & i & "]").Text = Cells(7 + i, 2)
.findById("wnd[0]/usr/ssubSUB_MAIN_CARRIER:SAPLMIGO:0006/subSUB_ITEMLIST:SAPLMIGO:0200/tblSAPLMIGOTV_GOITEM/txtGOITEM-ERFMG[4," & i & "]").Text = Cells(7 + i, 4)
.findById("wnd[0]/usr/ssubSUB_MAIN_CARRIER:SAPLMIGO:0006/subSUB_ITEMLIST:SAPLMIGO:0200/tblSAPLMIGOTV_GOITEM/ctxtGOITEM-ERFME[5," & i & "]").Text = "PC"
.findById("wnd[0]/usr/ssubSUB_MAIN_CARRIER:SAPLMIGO:0006/subSUB_ITEMLIST:SAPLMIGO:0200/tblSAPLMIGOTV_GOITEM/ctxtGOITEM-LGOBE[6," & i & "]").Text = "BORD"
.findById("wnd[0]/usr/ssubSUB_MAIN_CARRIER:SAPLMIGO:0006/subSUB_ITEMLIST:SAPLMIGO:0200/tblSAPLMIGOTV_GOITEM/ctxtGOITEM-NAME1[12," & i & "]").Text = "2S98"
.findById("wnd[0]/usr/ssubSUB_MAIN_CARRIER:SAPLMIGO:0006/subSUB_ITEMLIST:SAPLMIGO:0200/tblSAPLMIGOTV_GOITEM/ctxtGOITEM-UMLGOBE[27," & i & "]").Text = "DMDV"
.findById("wnd[0]/usr/ssubSUB_MAIN_CARRIER:SAPLMIGO:0006/subSUB_ITEMLIST:SAPLMIGO:0200/tblSAPLMIGOTV_GOITEM/ctxtGOITEM-UMBAR[32," & i & "]").Text = "CATNEW"
.findById("wnd[0]/usr/ssubSUB_MAIN_CARRIER:SAPLMIGO:0006/subSUB_ITEMLIST:SAPLMIGO:0200/tblSAPLMIGOTV_GOITEM/ctxtGOITEM-UMBAR[32," & i & "]").SetFocus
.findById("wnd[0]/usr/ssubSUB_MAIN_CARRIER:SAPLMIGO:0006/subSUB_ITEMLIST:SAPLMIGO:0200/tblSAPLMIGOTV_GOITEM/ctxtGOITEM-UMBAR[32," & i & "]").caretPosition = 6
.findById("wnd[0]/usr/ssubSUB_MAIN_CARRIER:SAPLMIGO:0006/subSUB_ITEMLIST:SAPLMIGO:0200/tblSAPLMIGOTV_GOITEM").verticalScrollbar.Position = i
.findById("wnd[0]").sendVKey 0
i = i + 1
Wend
End With
I tried using
.findById("wnd[0]/usr/ssubSUB_MAIN_CARRIER:SAPLMIGO:0006/subSUB_ITEMLIST:SAPLMIGO:0200/tblSAPLMIGOTV_GOITEM").verticalScrollbar.Position = i
to scroll down the list but apparently VBA still stops at line 23. Is there another for all my 200lines to be added inside the list?
Here is a picture of how it looks like when my code ran, There are lines below 23 but vba still stops and doesnt continue. Any help?
Hi Have you tried manually entering data above 23 lines? Are these lines are disabled after 23rd row?
Below should do the job. I usually scroll and set my last row on top. BTW Which t-code are you using?
.findById("wnd[0]/usr/ssubSUB_MAIN_CARRIER:SAPLMIGO:0006/subSUB_ITEMLIST:SAPLMIGO:0200/tblSAPLMIGOTV_GOITEM").verticalScrollbar.Position = i
Related
I am getting a runtime error when running this marco in excel. The code when rows = 1 works perfectly but I get a runtime error after the else. I can't seem to figure out the problem
If rows = 1 Then
Sheets("Sales Report").Range("C" & 1 + rows).Formula = "=SUMIFS('Stock Log'!$I$2:$I$1048576,'Stock Log'!$H$2:$H$1048576,B2,'Stock Log'!$B$2:$B$1048576,""<=""&A2)"
Else
Sheets("Sales Report").Range("C" & 1 + rows).Formula = "=SUMIFS('Stock Log'!$I$2:$I$1048576,'Stock Log'!$H$2:$H$1048576," & Cells(rows + 1, 2).Address & ",'Stock Log'!$B$2:$B$1048576,""<=""" & Cells(rows + 1, 1).Address & ",'Stock Log'!$B$2:$B$1048576,"">""" & Cells(rows, 1).Address & ")"
End If
I'm trying to flag problematic cells and link the cell hyperlink to another cell to review later. Here is my code. Not all of the code is visible. I Called "i" and "j" as long. The error occurs on newLink = Range("AL" & i).Hyperlinks(1).Address claiming that it is "out of range." I think this means that it is calling something that doesn't exist, but to be honest i'm not sure.
If Range("AK" & i).Value = "On" Then
If Range("AL" & i).Value = 0 And Range("AM" & i).Value = 0 Then
Range("AL" & i, "AM" & i).Interior.ColorIndex = 6
'Cells("AL" & i) = H.Address'
ErrorCount = ErrorCount + 1
Dim newLink As String
newLink = Range("AL" & i).Hyperlinks(1).Address
Range("IV" & j).Hyperlinks.Add anchor:=Range("IV" & j), Address:=Range("IV" & j)
Range("IV" & j).Hyperlinks(1).Address = newLink
j = j + 1
End If
If there is no hyperlink attached to a cell then Range("foo").Hyperlinks.Count will return 0 and therefore you will get an 'Out of range' error.
You just need to wrap the newLink = ... statement in an If to check if there is already a hyperlink there. E.g.
If Range("AL" & i).Hyperlinks.Count = 1 Then
newLink = Range("AL" & i).Hyperlinks(1).Address
Else
'what else will you do?
End If
What I have this far is below.
Range("F4").Value = Range("D4").Value & " x " & Range("E4")
This is creating a concatenate in Column F for me. This is working fine for the individual cell but I would like this to continue concatenating down until it hits an empty cell.
I have tried looping without success.
below is an image of the sheet
Set Concat= Rows(4)
concatstring =""
For i = 1 To Concat.Cells.Count
If Concat.Cells(i).Text <> "" Then
Concatstring = concatstring & " x " & Concat.Cells(i).Text
Else
Exit for
End If
Next
Concat.cells(I).text = concatstring
This should do it. Let me know if you still have problem.
Try this...
i=4
Do while(Range("D" & i).Value<> "")
Range("F" & i).Value = Range("D" & i).Value & " x " & Range("E" & i)
Loop
Looking for some guidance. I have created a statistics chart but also it lists the Top 5 WIP for certain categories.
the trouble I'm having is writing to text boxes on a chart. I have managed to do it with standard text boxes found on the insert tab but not with the ActiveX boxes which is what I need due to the need of scroll bars
Here is the function I have written to write strings to all text boxes.
Function Top5HeldCell(aSheet)
Dim row As Integer
Dim commentBox As TextBox
row = 12
For i = 4 To GetNumberOfEntries(aSheet, "A")
If Sheets(aSheet).Range("S" & i).Value <> "" Then
If Sheets(aSheet).Range("T" & i).Value = "" Then
rmNumber = Sheets(aSheet).Range("A" & i).Value
partNumber = Sheets(aSheet).Range("B" & i).Value
serialNumber = Sheets(aSheet).Range("C" & i).Value
ncNumber = Sheets(aSheet).Range("D" & i).Value
currentWIP = Sheets(aSheet).Range("W" & i).Value
Comments = Sheets(aSheet).Range("I" & i).Value
If row <= 16 Then
ActiveChart.Shapes.Range(Array("rmNumber" & row)).Select
Selection.ShapeRange(1).TextFrame2.TextRange.Characters.Text = rmNumber
ActiveChart.Shapes.Range(Array("partNumber" & row)).Select
Selection.ShapeRange(1).TextFrame2.TextRange.Characters.Text = partNumber
ActiveChart.Shapes.Range(Array("serialNumber" & row)).Select
Selection.ShapeRange(1).TextFrame2.TextRange.Characters.Text = serialNumber
ActiveChart.Shapes.Range(Array("ncNumber" & row)).Select
Selection.ShapeRange(1).TextFrame2.TextRange.Characters.Text = ncNumber
ActiveChart.Shapes.Range(Array("WIPTime" & row)).Select
Selection.ShapeRange(1).TextFrame2.TextRange.Characters.Text = currentWIP
' This works using standard textboxes
'ActiveChart.Shapes.Range(Array("comment" & row)).Select
'Selection.ShapeRange(1).TextFrame2.TextRange.Characters.Text = Comments
' here I'm trying to use ActiveX boxes
Charts("Statistics Chart").OLEObjects("comment" & row).Object.Text = ""
row = row + 1
End If
End If
End If
Next i
End Function
I seem to be getting the error 'Unable to get OLEObjects property of the Chart Class.
From using my nogging I expect this is something to do with the Charts not supporting this feature. Is there a work around that is known or am I really stuck???
Cheers
Private Sub Command4_Click()
Dim x As Integer
r = InputBox("Enter row size ")
c = InputBox("Enter column size ")
ReDim arr(r, c) As Integer
For i = 0 To r - 1 Step 1
For j = 0 To c - 1 Step 1
arr(i, j) = InputBox("Enter row : " & (i + 1) & "column size : " & (j + 1))
Next j
Next i
For i = 0 To r - 1
For j = 0 To c - 1
Text1.Text = Text1.Text & " " & arr(i, j)
Next j
Text1.Text = Text1.Text & vbNewLine & vbCr
Next i
End Sub
This is my code for taking inputs in an array. Here everything is working fine except this line "Text1.Text = Text1.Text & vbNewLine & vbCr" here I am trying to print the array in row-column in 2D form inside a text box but its not happening "vbNewLine or vbcr" both are not working and my array is getting printed in a single line.
I suggest vbCrLf instead of vbNewLine & vbCr, and you need to make sure you have your textbox set to Multiline in the properties editor.