AutoOpen dilemma

G

Greg Mc

I have a developed a form that is downloaded each time a
customer (many and varied) needs to use it from the
Internet.

The AutoOpen sub (code below)is located in the
ThisDocument module and does various things when the form
is first opened.

Public Sub AutoOpen()
On Error Resume Next
ActiveWindow.View.ShowHiddenText = True ' shows the
hidden text to the user. This text will not print
'Application.EnableCancelKey =
wdCancelDisabled 'disables the ability for a user to break
the macro
Application.CommandBars("Update Details").Visible =
True 'displays the update details toolbar. This calls the
updetails procedure afeter user has filled in all details
Application.CommandBars("Update Details").Position =
msoBarFloating 'Positions toolbar as floating
Set BMRange = ActiveDocument.Bookmarks
("bkRentorFin").Range 'sets a range for the bookmark
If BMRange.Text = "" Then 'if there is no data in the
above bookmark it means this is a new document and need to
open user form
Set BMRange = Nothing 'makes sure the range is set
back to nothing

frmSelOpt.Show 'shows form
End If
ActiveDocument.FormFields
("bkFullName").Select 'selects first field on form
ActiveWindow.View = wdPageView 'ensures page layout
view
End Sub

My dilemma is this, if a user selects the "open" option
when downloading off the Internet the frmselopt.show does
not load. Also if the form is saved as a template and a
user selects it via File New, again frmselopt.show does
not load. It is almost as if someone is pressing the
Shift key when opening the form. Eveything else in the
procedure works fine. Another oddity when opening from the
Internet is that if the "Browse in Same Window" option is
checked within file types under Explorer the
frmselopt.show works fine. It also works without a
problem when opening from a normal doc.

Curiously as well the line Application.CommandBars("Update
Details").Position = msoBarFloating seems to be ignored
when opening from a template. It places the tool bar in
the last opened position (docked or undocked).

The form was written in word 97 but works well in other
versions.

Your help will be most appreciated

Greg Mc
 
J

Jezebel

1. Code in a Word document will not run if the document is opened directly
from the Internet, for obvious security reasons. There's no work-around for
this that you can build in to your code. You have to tell people to download
the document, then open it with macros enabled. (And bear in mind, there are
plenty of corporate sites that block this, too -- as a matter of policy,
they don't permit *any* code downloads.)

2. If you create a new document from a template, AutoNew runs in place of
AutoOpen. A quick fix is to put your code into a separate Sub, called from
both AutoNew and AutoOpen -- then you catch it either way.
 
G

Guest

Thanks for that, makes perfect sense. We are actually
instructing them to download.

Greg Mc
 

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