![]() |
|
#1
|
|||
|
|||
|
Hi,
I tried some versions to start my Userform when Word starts. When you start word, a new document opens and shows. I tried to do: Private Sub Document_New() myForm.Show End Sub This works, when I start a new document and Word is open already, but works not when I start Word with this automatically created new document. Which code starts the Userform in unison with Word itself? Regards Dietrich |
|
#2
|
|||
|
|||
|
You might try adding the following code to your Normal.dotm. I usually keep such macros in a module called modAuto.
Code:
Public Sub AutoExec() myForm.show End Sub |
|
#3
|
|||
|
|||
|
Thanks for the fast answer!
The code you show me, I have set this accurate into the module of normal.dotm. But it doesn't work. I get the error message: Runtime error. 4248 This order is not available, because no document is open. What's to do? Greetings- Dietrich |
|
#4
|
|||
|
|||
|
My understanding is that it is best to create a new form rather than show the basic one. I believe this is a method of saving memory.
Code:
Sub StartUserForm()
Dim myNewForm As myForm
Set myNewForm = New myForm
myNewForm.Show
Unload myNewForm
Set myNewForm = Nothing
End Sub
|
|
#5
|
|||
|
|||
|
Quote:
Code:
Private Sub HaveABreak(iSeconds As Integer)
'
' Macro pauses running of procedure for given number of seconds
' Astrid Zeeland
' https://wordmvp.com/FAQs/MacrosVBA/ShowAllClippitAnimations.htm
'
Dim lPauseTime As Long
Dim lStart As Long
lPauseTime = iSeconds
lStart = Timer 'get current time
Do While Timer < lStart + lPauseTime
DoEvents
Loop
End Sub
You would call it with HaveABreak (i) where i is the number of seconds you need to wait. Try it with 1. Insert the following into the AutoExec macro before the Show command: HaveABreak(1) Last edited by Charles Kenyon; 01-28-2023 at 10:11 AM. |
|
#6
|
|||
|
|||
|
Thank you very much for the ideas!
I will try it tomorrow and send you a feedback. |
|
#7
|
||||
|
||||
|
Code:
Public Sub AutoExec() myForm.show End Sub What is it that the userform is supposed to achieve when Word is started.
__________________
Graham Mayor - MS MVP (Word) (2002-2019) Visit my web site for more programming tips and ready made processes www.gmayor.com |
|
#8
|
|||
|
|||
|
Hi Graham,
your idea was the right one. I had in the UserForm_initialize this code: Set oDoc = ActiveDocument. Now I have changed the programm into: Delete this line of code but insert Private Sub UserForm_Activate() If oDoc Is Nothing Then Set oDoc = ActiveDocument End Sub Now all is working! Thank you and have a nice Christmas! Dietrich (from Salzburg) |
|
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
Getting started...
|
Annby | Project | 3 | 11-06-2014 03:38 PM |
| VBA Code in a UserForm module to delete a Command Button which opens the userform | Simoninparis | Word VBA | 2 | 09-21-2014 03:50 AM |
Is it possible to take an input from a UserForm in one document to a UserForm in a do
|
BoringDavid | Word VBA | 5 | 05-09-2014 09:08 AM |
Page footers have started
|
ravl13 | Word | 3 | 11-21-2013 12:31 PM |
| Need Help Getting Started, Please. Thanks | ChunkyZergling | Outlook | 1 | 04-24-2009 07:38 AM |