Solved

Reading values by VBA of ComboBoxes/Textfields which are included directly in a table sheet

Posted on 2001-06-26
6
247 Views
Last Modified: 2012-06-21
Hi Experts,

how can I read the values of ComboBoxes,Textfields and other Objects, when they are included directly in an Excel sheet ?

It should start with ThisWorkbook.Sheets(1). ???

Thanks for the help

FFengler
0
Comment
Question by:FFengler
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
6 Comments
 
LVL 13

Accepted Solution

by:
cri earned 50 total points
ID: 6228438
Do you use Forms or Control Toolbox objects ?

For _Forms_ calacuccia answered this for me once in
http://www.experts-exchange.com/jsp/qManageQuestion.jsp?ta=msoffice&qid=10352410:

xxxxxxxxxxxxx

Ctrl defines the name of the form to be analysed, description = 1 will tell  if the choosen item in the ListBox or ComboBox has to be displayed instead of the value. The value of Description is negliged for CheckBox and OptionButton forms.

Function MyRet(Ctrl As String, Description As Boolean)
Dim mctr As Shape

Application.Volatile 'Only if used from worksheet side
Set mctr = ActiveSheet.Shapes(Ctrl)

If mctr.Type <> msoFormControl Then Exit Function

Select Case mctr.FormControlType
   
   Case xlListBox
   If Description = 0 Then
       MyRet = mctr.ControlFormat.Value
   Else
       MyRet = ActiveSheet.Range(mctr.ControlFormat.ListFillRange).Cells(mctr.ControlFormat.Value)
   End If

   Case xlDropDown
   If Description = 0 Then
       MyRet = mctr.ControlFormat.Value
   Else
       MyRet = ActiveSheet.Range(mctr.ControlFormat.ListFillRange).Cells(mctr.ControlFormat.Value)
   End If

   Case xlCheckBox
   If mctr.ControlFormat.Value = -4146 Then
       MyRet = True
   Else
       MyRet = False
   End If

   Case xlOptionButton
   If mctr.ControlFormat.Value = -4146 Then
       MyRet = True
   Else
       MyRet = False
   End If

End Select

End Function
0
 

Author Comment

by:FFengler
ID: 6231252
Hello cri,

I included your Function into my Code. When I tried to read the value of a Checkbox which is directly included in a Sheet, I get an error within your function because the Checkbox  cannot be found.

The call of the function is as follows:

 s.verz = MyRet("VerzeichnisBox", False)

"VerzeichnisBox" is the name of the Checkbox
I changed the function to refer to a special Sheet in the workbook:

Instead of
Set mctr = ActiveSheet.Shapes(Ctrl)

I use
   
Set mctr = ThisWorkbook.Sheets("Allgemein").Shapes(Ctrl)

which should also work.


where's the mistake here ?

Thanks
0
 
LVL 13

Expert Comment

by:cri
ID: 6232377
Sorry to re-ask: Do you use Forms or Control Toolbox objects ?

0
Office 365 Training for IT Pros

Learn how to provision tenants, synchronize on-premise Active Directory, implement Single Sign-On, customize Office deployment, and protect your organization with eDiscovery and DLP policies.  Only from Platform Scholar.

 
LVL 13

Expert Comment

by:cri
ID: 6232381
If unsure, check under View|Toolbar
0
 

Author Comment

by:FFengler
ID: 6242091
Hi cri,

I am using Control Toolbox objects (out of the control Toolbox) which I put directy into a table sheet, I am not using a form for this.

0
 
LVL 13

Expert Comment

by:cri
ID: 6243025
As stated in my post of 06/26/2001 the code reads the values for Form _objects_. These are the predecessors of the ActiveX bloats. I use nothing else.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
My attempt to use PowerShell and other great resources found online to simplify the deployment of Office 365 ProPlus client components to any workstation that needs it, regardless of existing Office components that may be needing attention.
Learn how to make your own table of contents in Microsoft Word using paragraph styles and the automatic table of contents tool. We'll be using the paragraph styles in Word’s Home toolbar to help you create a table of contents. Type out your initial …
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question