Userform troubleshooting

S

Sasa

Hi,
Im trying to create an Userform that will apear when the
specified document is opened. So, where shall i put my
code for activation of userform when this document is
opened? Also, how shall this code look like?
Thanks.

Help is very appreciated.

Regards.
Sasa.
 
H

Helmut Weber

Hi Sasa,
like this:
Sub AutoOpen()
If ActiveDocument.Name = "Mydoc.doc" Then
Myform.Show
End If
End Sub
Note: If ActiveDocument.Name = "Mydoc.doc" is
case sensitive.
Greetings from Bavaria, Germany
Helmut Weber
"red.sys" & chr$(64) & "t-online.de"
Word 97, NT 4.0
 
S

Sasa

Code look fine but it still doesnt work. You havent told
me where shall i put this code. Shall it be in "General"
part or where else? Word just wont start the userform when
document is opened.
Thanks.

Regards.
Sasa
 
H

Helmut Weber

Hi Sasa,
the code resides in my normal.dot,
but could as well be in an add-in.
Have You got a userform at all?
Are there no typing errors,
regarding the document's name?
Try this as a start, to find out,
whether autoopen is running at all.
sub Autoopen
msgbox "autoopen"
end sub
How do You open the document?
AutoMacros like autooen, autoexec etc. do not run
under all possible conditions.
Maybe somebody else knows better.
Greetings from Bavaria, Germany
Helmut Weber
"red.sys" & chr$(64) & "t-online.de"
Word 97, NT 4.0
 
D

Dave Neve

Hi

I've also tried to follow this conversation with its few lines of code.

My code

Sub UpOnScreen()
'
' UpOnScreen Macro
' Macro créée le 23/12/2003 par Dave Neve
'
Private Sub AutoOpen()
If ActiveDocument.Name = "VB_Test1.doc" Then
Myform.Show
End If
End Sub

apparently has an error on the 5th line where there is a '

The error is 'end sub expected/awaited' (translated from French so the exact
wording may be out.

I then tried

Sub TestAutoOpen()
'
' TestAutoOpen Macro
' Macro créée le 23/12/2003 par Dave Neve
'
Sub Autoopen()
MsgBox "autoopen"
End Sub

and got the error 'ambiguous name detected' on the Sub Autoopen() line

I still can't get anything to work and it's not for lack of trying.

Is it VB or is it me?

Thanks
 
J

Jonathan West

Hi Dave

You have two Sub statements without having an End Sub between them. Decide
what name your routine will have, and delete the other Sub statement.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top