Solved

Global Variables for ActiveX Documents

Posted on 1999-01-06
2
258 Views
Last Modified: 2011-09-20
Hi, I am creating some ActiveX Documents for IE3.02 and 4.x, and I created them all in a single project file (ActiveX EXE). I have also some variables declared Global with a default value in a module file.

What I wanted is: when I change the values of these global variables in, say document A, I need these new values to be accessible by other documents. What I did was, when I click a "Next" button on Document A, which has a Hyperlink.NavigateTo "a html with Document B embedded", the global value remains the default on Document B even though Document A has changed it one step before.

Pls help! Thanks.
0
Comment
Question by:totoro030898
2 Comments
 
LVL 15

Expert Comment

by:ameba
ID: 1454458
1. If you start your ActiveX EXE 3 times, each instance has its own independent global variables. One way to share variable values is via registry or your own ini or log file.

2. It is easier if you have *only one* instance of ActiveX EXE running and creating all objects. Then each object can access all global variables directly.

3. You can add ActiveX DLL to your ActiveX EXE project references.
Start new ActiveX DLL. Class1 is created by default. Paste this to your Class1:
Option Explicit

Public Property Get GlobalVar() As String
    GlobalVar = gGlobalVar
End Property

Public Property Let GlobalVar(ByVal sNewValue As String)
    gGlobalVar = sNewValue
End Property

Add module to your project. Paste this 2 lines to module1:
Option Explicit
Public gGlobalVar As String

Create dll (project1.dll)

In your ActiveX EXE (or Standard EXE) add reference to project1.dll
To access Global variable, use:
   Dim x As New Project1.Class1
   MsgBox x.GlobalVar ' get variable
   x.GlobalVar = "Document X" ' set variable

Each of your 3 EXEs will create its own x object. But, only 1 DLL will be loaded. Its usage count will be 3.
--
Maybe solution 1. is the simplest
0
 

Accepted Solution

by:
Ajoy earned 100 total points
ID: 1454459
totoro,
I am submitting this as an answer though i think part of the answer has already been given by 'ameba'.

You can have a Dll with a single class module with as many number of properties as your global variables. In ur 'ActiveX Document A' create an object of this class and whenever u change the values of the global variables, assign it to the object properties accordingly.
On the Click of the 'Next' button in 'document A' pass this object as a reference to 'Document b'. Then assign to the global variables in 'Document b' the property values of this object.
This will make  the global variables in 'document b' to have the new values.
This should solve ur problem.
u can contact me at
Ajoy.tarafder@in.bosch.com
regards,
Ajoy
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
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…
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…

743 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