Naming Dimensions not functioning.

fwk

New Member
Joined
Jan 9, 2024
Messages
6
Office Version
  1. 365
Platform
  1. Windows
Users input a plant number in a Excel worksheet cell (J2) as indicated below. I have set a dimension to pick data from this cell and input it into a SAP transaction.

1705025087562.png

My VBA code is the following.

' Copy in the plant number
session.findById("wnd[0]/usr/ctxtIWERK-LOW").Text = "2004"
session.findById("wnd[0]/usr/ctxtIWERK-LOW").SetFocus
session.findById("wnd[0]/usr/ctxtIWERK-LOW").caretPosition = 4
session.findById("wnd[0]/usr/btn%_REVNR_%_APP_%-VALU_PUSH").press

This works fine. The problem start when I change the "2004" plant number to reflect the dimension criteria to enable to read the input cell (J2) value. No input from (J2) is transferred to the SAP transaction.
I have change the above code to the following code:-

' Copy in the plant number
session.findById("wnd[0]/usr/ctxtIWERK-LOW").Text = selectedSite
session.findById("wnd[0]/usr/ctxtIWERK-LOW").SetFocus
session.findById("wnd[0]/usr/ctxtIWERK-LOW").caretPosition = 4
session.findById("wnd[0]/usr/btn%_REVNR_%_APP_%-VALU_PUSH").press


I declare the point of pickup (J2) as per below.

Dim selectedSite As String
selectedSite = ActiveWorkbook.ActiveSheet.Range("J2").Value

What am I doing wrong? Any help is appreciated.
FWK
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
What happens if you try:
selectedSite = CStr(ActiveWorkbook.ActiveSheet.Range("J2").Value2)
 
Upvote 0
Also, are the correct workbook and worksheet active when the code runs?
 
Upvote 0
Thanks for the feedback. I will test it today.
 
Upvote 0
What happens if you try:
selectedSite = CStr(ActiveWorkbook.ActiveSheet.Range("J2").Value2)

Folder Path for ALL downloads from SAPSAP Transaction 1Variant Name -IW39Download Filename IW39SAP Transaction 2Variant Name - SparesDownload Filename /SVNT/MATERIAL_STATSAP Transaction 3Download Filename IWBKPlant CodeSAP Revision CodesWork Order Numbers
C:\Users\10005500\OneDrive - Newmont USA Limited\Desktop\SAP Automated data extraxt\Material Report\SAP Downloads\IW39WKSPARESIW39 Dwnld/N/SVNT/MATERIAL_STATU-WK SOH REPSVNTMATERIAL_STAT DwnldIWBKIWBK Dwnld2004TF24WP0123099407
TF24DP0123017451


Below is a screenshot of the excel workbook where the data needs to be read from. A2 and J2 needS to be read. This spaces in the blue cells is where I need users to type in criteria related to their plant and file safe preferences. I do not want the to scratch in the VBA as I will protect that.
1705285255612.png

Below is my code which work as expected. The moment i change it to point to the excel cells it doesn't transfer the inputs to SAP.

1705286636792.png


I have tried your code above and it DOESNT LIKE IT. Do i misunderstood what you want me to do with your code?
1705286742064.png


Your code hangs up here.

1705286991150.png
 
Upvote 0
selectedSite should be declared as String, not as Integer.
 
Upvote 0
selectedSite should be declared as String, not as Integer.

I have tried the above suggestion and it also have the same issue. I have thought about this statement of yours "are the correct workbook and worksheet active when the code runs?" and checked that and it sems OK.
 

Attachments

  • Problem.gif
    Problem.gif
    104.2 KB · Views: 6
  • Error.gif
    Error.gif
    25.7 KB · Views: 6
Upvote 0
Can you add in a line to make sure the variable has the right value:

VBA Code:
msgbox selectedSite
' Copy in the plant number
session.findById("wnd[0]/usr/ctxtIWERK-LOW").Text = selectedSite
 
Upvote 0

Forum statistics

Threads
1,215,086
Messages
6,123,043
Members
449,092
Latest member
ikke

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top