Automatically display a form when opening a template file, dotm from explorer

I wrote a macro for creating form-based documents (in VBA) for distribution to a sales team.

For ease of use, I want to provide an offline file that displays the form immediately after opening the document.

Using AutoOpen, I can get the form to display as intended if the word is already open and the dotm file opens inside. However, if I double-click the file from Explorer, nothing will happen, and I have to run the macro manually. I thought AutoExec might allow it, but no luck. I spent a lot of time trying to get this to work through googling, etc., but I won’t go anywhere.

How can I display a form even when a file is opened with a double click? Is it possible to do this without changing normal.dotm for each user?

For more information, I use Word 2013 with fully included macros during testing. Dotm file is stored in a safe place.

I am using a macro to run a form like this ...

Public Sub AutoOpen()
    StartPage.Show
End Sub

I tried using AutoExec, but to no avail.

+4
source share
1 answer

In the file "generator.dotm" that got into Visual Basic, and go to the "Microsoft Word Object" of this document.

Visual Basic "" , "" . Private Sub Document_New() . . :

Private Sub Document_New()

    Dim myForm As UserForm1
    Set myForm = New UserForm1

    myForm.Show

End Sub

Generator.dotm Windows, , .

+5

Source: https://habr.com/ru/post/1546545/


All Articles