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
Solved

VBA Object!

Posted on 2001-08-07
9
242 Views
Last Modified: 2010-05-02
If I add some VBA object in a word document (let's say a checkbox) how can I interact with it in my regular VB application? (Changing/reading its property) ??

0
Comment
Question by:nfuids
  • 4
  • 3
  • 2
9 Comments
 
LVL 6

Expert Comment

by:xSinbad
ID: 6362496
Give the object a name like chkName then use the VBE to refernce it.
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 6365090
hearing... no so simple xSinbad
;)
0
 

Author Comment

by:nfuids
ID: 6365708
I need some sample...
0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 6

Accepted Solution

by:
xSinbad earned 50 total points
ID: 6366205
An example from MS;

Dim i As Integer

Private Sub CommandButton1_Click()
    TextBox1.Text = "Value of " & ActiveControl.Name & " is " & ActiveControl.Value
End Sub

Private Sub UserForm_Initialize()
    CommandButton1.Caption = "Get value of current control"
    CommandButton1.AutoSize = True
    CommandButton1.TakeFocusOnClick = False
    CommandButton1.TabStop = False
   
    TextBox1.AutoSize = True
   
    For i = 0 To 10
        ComboBox1.AddItem "Choice " & (i + 1)

        ListBox1.AddItem "Selection " & (100 - i)
    Next i
   
    CheckBox1.TripleState = True
    ToggleButton1.TripleState = True
   
    TextBox2.Text = "Enter text here."
End Sub

0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 6367740
This code is used within vba, no outside in VB.
0
 

Author Comment

by:nfuids
ID: 6367898
But how could I call Private Sub CommandButton1_Click() from my VB application??
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 6368136
That's what i mean....
0
 
LVL 6

Expert Comment

by:xSinbad
ID: 6370313
Sorry about that I had just finished answering some questions in the Office area and my brain still hadnt swithced topics. You can use automation.

example;

Function AccessWordObject()
Dim objWD As Object
Dim strFlName As String

strFlName = FILE NAME
Set objWD = GetObject(, "Word.Application")

Set objWD = GetObject(strFlName)

   With objWD.Application
' ***********************************************
    ' Place you VBA code in here  
      .Application.Run "Macro.Function"

" ***********************************************
   End With

   Set objWD = Nothing

End Function
0
 
LVL 6

Expert Comment

by:xSinbad
ID: 6405178
How are you going with this one nfuids ?
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

840 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