Control Word Document/ Current Instance from within Access

G

Gina

Hi all.

I am trying to customise Word for a particular template
( wanted to avoid macros in word )

I have 2 public variables:

Dim wrd As New Word.Application
Dim DC As Word.Document

which get initialised:
.....
Set wrd = New Word.Application
Set DC = wrd.Documents.Add("C:\Temp\My.dot")
isPrepaired = HideAllToolbars(wrd, DC)
......
the bottom function hides all the toolbars exept my own - fine so far
but when the user creates a new instance of word directly (through
normal.dot) as long as my document is still open, no commandbars are there
in that normal version of word :-((
I created a macro that re-enables all the available toolbars when closing my
document
so when my document is closed all is fine and word creates all the normal
commandbars.

Questions:
How can I catch only the currentInstance I created in access and apply my
hiding stuff only to that one ??
or
Do I have to create a macro in the global normal.dot to enable expicitely
toolbars when my document is open ?
(wanted to avoid stuff like that)

Many thanks for your help.

Gina

***
Function HideAllToolbars(curWRD As Word.Application, curDC As Word.Document)
Dim i As Integer
i = 1

curWRD.EnableCancelKey = wdCancelDisabled
curWRD.WindowState = wdWindowStateNormal

Do
curWRD.CommandBars(i).Enabled = False
i = i + 1
Loop While i <= (curWRD.CommandBars.Count)

curWRD.CommandBars.AdaptiveMenus = False
curWRD.CommandBars("Toolbar List").Enabled = False
curWRD.CommandBars("Rechnung").Enabled = True
curWRD.CommandBars("Rechnung").Visible = True
curWRD.EnableCancelKey = wdCancelInterrupt

End Function
 
T

Tony Jollans

Hi Gina,

Your tailoring is being done by default to the normal template. Before doing
it, try setting the Customization Context


Function HideAllToolbars(curWRD As Word.Application, curDC As Word.Document)
Dim i As Integer
i = 1

CustomizationContext = curDC.Attachedtemplate

curWRD.EnableCancelKey = wdCancelDisabled
curWRD.WindowState = wdWindowStateNormal

etc., etc.
 
G

Gina

Hi Tony

Thanks for your fast answer!!
I have just added your line at the beginning as you suggested .... but
unfortunatley it doesn't help.
....as long as my document in my instance of word is open, normal.dot still
shows up with removed toolbars....

?:-|
Gina
 
G

Gina

Arvin,

yes, wrong group that were my fears as well so I did a cross-posting
.... but windows question !!?.... oh no .... (how painful)

Gina
 
T

Tony Jollans

Hi Gina,

Sorry, I thought that would make a difference - and it does, sort of.

When you have the "Windows in Taskbar" (under Tools > Options > View) set
then you can have different commandbars in each Word window. When it is not
set you only have the one 'window' (terminology is difficult here) and one
set of active commandbar settings.

You could control it further using Application Events to enable or disable
the command bars when changing documents. But do you really want to give
control back to the user in this way - it could destroy all your careful
tailoring. As I'm sure you know from the various replies to your posts you
can't have 100% success with this - whatever you do will be a compromise so
is it necessary for users to be opening other documents with full control
while they are interacting with your access-based word application?
 
G

Gina

Sorry, I thought that would make a difference - and it does, sort of.

well I am sure it does something.... I had to change my code to take the
public variables as follows
...
wrd.CustomizationContext = DC.AttachedTemplate

wrd.EnableCancelKey = wdCancelDisabled
wrd.WindowState = wdWindowStateNormal
....
now stepping through before DC.AttachedTemplate is assigned to Context,
wrd.CustomizationContext has 'normal.dot' as its value!!!

after executing that line it has 'My.dot'
When you have the "Windows in Taskbar" (under Tools > Options > View) set
then you can have different commandbars in each Word window. When it is not
set you only have the one 'window' (terminology is difficult here) and one
set of active commandbar settings.

I work in office 2000 German version ... I have tried to find out the
equivalent of what you describe .... not really successfully
You could control it further using Application Events to enable or disable
the command bars when changing documents. But do you really want to give
control back to the user in this way - it could destroy all your careful
tailoring. As I'm sure you know from the various replies to your posts you
can't have 100% success with this - whatever you do will be a compromise so
is it necessary for users to be opening other documents with full control
while they are interacting with your access-based word application?

Exactly .... that was going through my head as well (after post was
sent).... maybe it is better as it is now ... so users have to first finish
my stuff ( with word) and then could do whatever they like in Word and
anywhere else ;-).... so yes you are right I do not want the full stuff!!

I learned quite a bit doing this customisation thing with the group
and the result gives me kind of 'security' - one eye kept closed ;-)
..... so I am fairly happy with it

Many Thanks Tony,

Gina
 
T

Tony Jollans

Word 2000 doesn't have the "Windows in Taskbar" option - it is always
effectively on. The option was in Excel in 2000 but not introduced into Word
until XP (2002).

It is perfectly possible to have different commandbar settings in different
documents/templates and I would have expected setting the customization
context to have done it. However it seems that more explicit action is
required to achieve it; there is clearly something I'm not understanding
here but as you have decided against the approach I will leave it to another
time to investigate fully.
 
G

Gina

Thanks Tony....
for all the thinking into my problem, your good advice and help!!!!

I am very thankful !!
Gina
 

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