Solved

VBA Object!

Posted on 2001-08-07
9
226 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
Comment Utility
Give the object a name like chkName then use the VBE to refernce it.
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
Comment Utility
hearing... no so simple xSinbad
;)
0
 

Author Comment

by:nfuids
Comment Utility
I need some sample...
0
 
LVL 6

Accepted Solution

by:
xSinbad earned 50 total points
Comment Utility
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
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 
LVL 16

Expert Comment

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

Author Comment

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

Expert Comment

by:Richie_Simonetti
Comment Utility
That's what i mean....
0
 
LVL 6

Expert Comment

by:xSinbad
Comment Utility
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
Comment Utility
How are you going with this one nfuids ?
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

772 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now