Highlighted
Frequent Contributor.
Frequent Contributor.
1151 views

How to write in excel drop down list / combobox using uft

Jump to solution

Hello,

I really need some help here. I have to select / write something in an excel dropdown list (manually it is possible to select a value from the dropdownlist or to write it in the box).

Capture.PNG

I have the following code:

set objExcel = createobject("excel.application")
objExcel.Visible=True
set objWB = objExcel.workbooks.open ("<path>\name.xlsm", readonly=False)
set objsheet = objwb.worksheets("Project")
objwb.Worksheets("Project").Activate

I've tryied in several ways, including  objsheet.Cells(16,2) = "4162-P-0001",  without success.

Thank you in advance for your help!

0 Likes
1 Solution

Accepted Solutions
Highlighted
Knowledge Partner
Knowledge Partner

Re: How to write in excel drop down list / combobox using uft

Jump to solution

That may be the issue, I created the list via 'Data Validation' and listed the valid values as 1,2,3,4,5 hen ran the following:

set objExcel = createobject("excel.application")
objExcel.Visible=True
set objWB = objExcel.workbooks.open ("C:\Temp\Temp.xlsx", readonly=False)
set objsheet = objwb.worksheets("Project")
objwb.Worksheets("Project").Activate
objsheet.Cells(1,1).Value = 1

which selected 1 in the list

If you are using an ActiveX you need to do something like:

objsheet.Combobox1.Value = "My Selected Value"

You will have to change the Combobox1 to the value of your combobox - Go into design mode, right-click on list and select properties - Name should be 1st property

Mark Smith.

View solution in original post

5 Replies
Highlighted
Knowledge Partner
Knowledge Partner

Re: How to write in excel drop down list / combobox using uft

Jump to solution

You are almost there, you just need to append .Value to you command:

objsheet.Cells(16,2).Value = "4162-P-0001"

Mark Smith.

0 Likes
Highlighted
Frequent Contributor.
Frequent Contributor.

Re: How to write in excel drop down list / combobox using uft

Jump to solution

I've tried this also and it doesn't work. The old value remains in the field.

0 Likes
Highlighted
Frequent Contributor.
Frequent Contributor.

Re: How to write in excel drop down list / combobox using uft

Jump to solution

I'm not sure if this may be a cause, but I have to mention that the drop down is done via a vba script.

0 Likes
Highlighted
Knowledge Partner
Knowledge Partner

Re: How to write in excel drop down list / combobox using uft

Jump to solution

That may be the issue, I created the list via 'Data Validation' and listed the valid values as 1,2,3,4,5 hen ran the following:

set objExcel = createobject("excel.application")
objExcel.Visible=True
set objWB = objExcel.workbooks.open ("C:\Temp\Temp.xlsx", readonly=False)
set objsheet = objwb.worksheets("Project")
objwb.Worksheets("Project").Activate
objsheet.Cells(1,1).Value = 1

which selected 1 in the list

If you are using an ActiveX you need to do something like:

objsheet.Combobox1.Value = "My Selected Value"

You will have to change the Combobox1 to the value of your combobox - Go into design mode, right-click on list and select properties - Name should be 1st property

Mark Smith.

View solution in original post

Highlighted
Frequent Contributor.
Frequent Contributor.

Re: How to write in excel drop down list / combobox using uft

Jump to solution

It worked like this. Thank you very much!

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.