Solved

VBA Object!

Posted on 2001-08-07
9
251 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
[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
  • 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
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 
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: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
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…

751 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