Solved

VBA Object!

Posted on 2001-08-07
9
238 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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
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

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

803 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