PDA

View Full Version : Open Userform From a Macro



gibbo1715
01-27-2005, 02:22 AM
I need to be able to open a userform from a template in word97

I can do it in word 2000 with the On New command but this doesnt work in word 97

Is It possible in word 97?

If so how

Help!!!!!!!

Jacob Hilderbrand
01-27-2005, 02:45 AM
You can use this to open the UserForm.

UserFormName.Show

If you want it to automatically run when the template is opened then you need to check what events are available. Its been a while since I have used Office 97 so I am not 100% sure what events are available to you. Go to the VBE and double click on ThisDocument. From the left drop down (above the Code Window) select Document. From the right drop down see if there is an event you can use like New or Open.

gibbo1715
01-27-2005, 02:51 AM
Thanks Jake, thats what I have but wont work on word 97, i was wondering if the on new command only became available in word 2000? the other thing i considered is I created the template in word 2000 so maybe thats my problem?

Any ideas

Jacob Hilderbrand
01-27-2005, 03:11 AM
Open a new doc in Word 97 and check the events. Are there any available?

Howard Kaikow
01-27-2005, 06:50 AM
You can use this to open the UserForm.

UserFormName.Show

If you want it to automatically run when the template is opened then you need to check what events are available. Its been a while since I have used Office 97 so I am not 100% sure what events are available to you. Go to the VBE and double click on ThisDocument. From the left drop down (above the Code Window) select Document. From the right drop down see if there is an event you can use like New or Open.
Word 97 is nearly brain dead as far as application events are concerned.

Steiner
01-31-2005, 02:28 AM
This one should work in the template in Word97:
Option Explicit

Private Sub Document_New()

UserForm1.Show

End Sub

Howard Kaikow
01-31-2005, 06:41 AM
Thanks Jake, thats what I have but wont work on word 97, i was wondering if the on new command only became available in word 2000? the other thing i considered is I created the template in word 2000 so maybe thats my problem?

Any ideas
What is the "On new" command?

It's not in the object browser.

gibbo1715
01-31-2005, 10:37 AM
in word 2000 as well as the onopen() event there is an Onnew() event that will run a macro from a template when creating a new document, doesnt seem to be available in word 97

TonyJollans
01-31-2005, 01:45 PM
gibbo,

It would help if you were precise in your terminology (unless you are, and there's something none of us know).

The Document_New Event exists in Word 97. What makes you think it doesn't?

The AutoNew macro can also be used.

As Howard so succinctly said, Word 97 is a bit lacking in Application events (although it does have a DocumentChange event which will fire) but you don't need to use them for this.

Howard Kaikow
01-31-2005, 04:07 PM
in word 2000 as well as the onopen() event there is an Onnew() event that will run a macro from a template when creating a new document, doesnt seem to be available in word 97
That's Document_New and Document_Open events, not OnOpen or OnNew commands.

If you need to do serious Word VBA, you really do need Word 2000 or later.

fumei
02-15-2005, 09:15 AM
Is Word 97 even VBA? I thought it was still WordBasic. Silly me, but then I have never used 97. However, as Tony points out, AutoOpen and AutoNew macros have been around a while. Since Word 3.0 I believe.

gibbo1715
02-15-2005, 11:03 AM
managed to get it working (sort of), word 97 is not that useful when using code is it!!! roll on when my company has completely migrated to word 2000


Thanks for all your help guys :)

Steiner
02-16-2005, 01:39 AM
And Gerry, believe it or not, Word97 has VBA
(I think it was the first Word to have it) because only 3 years ago I should migrate an application running under Word 6 (WordBasic) to 97 :banghead: .

Fortunately, I could convince my boss that creating a new Software from the scratch using VB 6 & VBA would be far more effective.

Howard Kaikow
02-16-2005, 09:29 AM
Is Word 97 even VBA? I thought it was still WordBasic. Silly me, but then I have never used 97. However, as Tony points out, AutoOpen and AutoNew macros have been around a while. Since Word 3.0 I believe.

Word 97 was the first VBA version of Word.