Question

Locked

Trying to change combo box value in Excel from an outside VB6 program.

By Slayer_ ·
I got an excel document with a combobox in a cell.
It has the values
"Commercial"
"Agricultural"

I have a VB6 program that opens this protected excel document, and auto fills data that we already know.

This combobox value is vital as it changes how the spreadsheet bases it's calculations. How can I change it's value? The spreadsheet is not visible during the pre-population.

For legal reasons, I am not allowed to change the document in any way. No adding code or changing layouts or anything. All my work must be contained within the VB6 program.


-Edit
It seems there are two types of Excel combo boxes. One that is done using form fill in fields that are changable even if the document is protected. And the VBA forms style which drops a windows like combo box into a cell. The latter is the one used in this document and what is causing my trouble. I need to change its value from outside. According to my boss, I am not allowed to just use a series of FindWindow and SendMessage commands to solve this.

This conversation is currently closed to new comments.

18 total posts (Page 1 of 2)   01 | 02   Next
| Thread display: Collapse - | Expand +

All Answers

Collapse -

Would this be of help?...

Though Method 2 (though it says "Methdod") might be what you are looking for.
http://support.microsoft.com/kb/161598

Collapse -

Sadly its not helpful

by Slayer_ In reply to Would this be of help?...

That just explains how to do it within Excel, which is of course easy, but from outside excel...

Even just getting an hwnd valud of the box would be acceptable... but I can't find anyways to get excel to give me information about its VBA controls.

Collapse -

These are some Excel VBA Code For Excel UserForms & Controls

by Peconet Tietokoneet In reply to Sadly its not helpful

http://www.ozgrid.com/VBA/UserForms.htm

OR maybe:
http://www.excel-vba.com/excel-vba-solutions-advanced.htm

Collapse -

Still the wrong way

by Slayer_ In reply to These are some Excel VBA ...

This only lets me change values from Within Excel VBA, not from the outside.

It's really hard to search for, I wonder if anyone has ever done this.

Collapse -

Bump

by Slayer_ In reply to Would this be of help?...
Collapse -

I have found a way to do it, but it is extremely undesired method

by Slayer_ In reply to Trying to change combo bo ...

I added a public sub to the sheet.

Public Sub ChangeType(ByVal sType As String)
Me.cboType.Text = sType
Call cboType_Click
End Sub


And wrote this code in VB6
Call oExcel.Run("Sheet1.ChangeType", "Agricultural")

And it works. BUT I do not want to be reliant on this changed spreadsheet, as the sheet can be changed without warning, thus losing the macro when a new version of this template is released.

I need a better way of doing this.

And thanks for trying Peconet Tietokoneet. You'll get thumbs if I get this resolved.

Collapse -

Can you not Save the Macro in question?.... NT

by Peconet Tietokoneet In reply to I have found a way to do ...
Collapse -

For legal reasons, the document must remain unchanged

by Slayer_ In reply to Can you not Save the Macr ...

If the modification date is changed or the MD5, it needs to go through legal department and be revalidated.

At the moment, we are just hoping to get away with it, cause the contents of the document are unchanged, I just added a sub. But I would much rather a direct way to do it.

Collapse -

This might be of some help..

by Peconet Tietokoneet In reply to I have found a way to do ...

http://office.microsoft.com/en-us/excel/HA010872961033.aspx

Collapse -

Also found "Track/Report User Changes on an Excel Worksheet/Workbook"

by Peconet Tietokoneet In reply to I have found a way to do ...
Back to Software Forum
18 total posts (Page 1 of 2)   01 | 02   Next

Related Discussions

Related Forums