Discussion:
Running Word 2003 template/macros in Word 2007
(too old to reply)
NigelG
2009-01-09 18:47:56 UTC
Permalink
I've been developing some macros in W03, & would like them to work in
W07 too. Recently a friend running W07 reported the following error
when he tried attaching one of these templates:

<quote>

Run-time error '-2147467259 (80004005)':
Method 'Visible' of object 'CommandBar' failed

</quote>

The relevant section of the AutoNew macro in the VBA is as follows:

With CommandBars("ZipCzech")
.Visible = True

'initialize control buttons
For i = 1 To 4
If i <> 2 Then .Controls(i).State = False
Next i
End With
MsgBox "Ready to type Czech", , "ZipCzech"
End Sub



Does the problem arise from the fact that W07 doesn't recognize
Command Bars? I'd be grateful for any suggestions about a workaround.

Nigel
Doug Robbins - Word MVP
2009-01-12 01:31:14 UTC
Permalink
Almost certainly, that is the cause of the problem.

To prevent the error, you could have the code check for the Version of Word
that is being used and only execute those lines of code if it is <11
--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
Post by NigelG
I've been developing some macros in W03, & would like them to work in
W07 too. Recently a friend running W07 reported the following error
<quote>
Method 'Visible' of object 'CommandBar' failed
</quote>
With CommandBars("ZipCzech")
.Visible = True
'initialize control buttons
For i = 1 To 4
If i <> 2 Then .Controls(i).State = False
Next i
End With
MsgBox "Ready to type Czech", , "ZipCzech"
End Sub
Does the problem arise from the fact that W07 doesn't recognize
Command Bars? I'd be grateful for any suggestions about a workaround.
Nigel
NigelG
2009-01-12 11:22:13 UTC
Permalink
On Jan 12, 1:31 am, "Doug Robbins - Word MVP"
Post by Doug Robbins - Word MVP
Almost certainly, that is the cause of the problem.
To prevent the error, you could have the code check for the Version of Word
that is being used and only execute those lines of code if it is <11
Many thanks for the reply. I've just checked my version of Word 03, &
it seems to be V. 11.something. So I presume I should check for
Version <= 11.

Nigel
Doug Robbins - Word MVP
2009-01-13 01:59:50 UTC
Permalink
Or <12, which is what I should have suggested.
--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

"NigelG" <***@yahoo.co.uk> wrote in message news:3c195c02-0d42-4df2-a6b1-***@v18g2000pro.googlegroups.com...
On Jan 12, 1:31 am, "Doug Robbins - Word MVP"
Post by Doug Robbins - Word MVP
Almost certainly, that is the cause of the problem.
To prevent the error, you could have the code check for the Version of Word
that is being used and only execute those lines of code if it is <11
Many thanks for the reply. I've just checked my version of Word 03, &
it seems to be V. 11.something. So I presume I should check for
Version <= 11.

Nigel
NigelG
2009-01-13 18:37:02 UTC
Permalink
On Jan 13, 1:59 am, "Doug Robbins - Word MVP"
Post by Doug Robbins - Word MVP
Or <12, which is what I should have suggested.
As a footnote, I've now installed both versions of Word (2003 & 2007)
on my computer, & find that the templates & macros from W03 work
perfectly well in W07 after all (once the security settings are
adjusted to allow macros to run). The custom CommandBar appears, as
it should, under the Add-ins tab of W07 -- I haven't yet quite worked
out why my friend is having a problem with that .Visible=True
statement. Maybe something to do with his Vista OS?? (I'm using XP.)

Nigel

Loading...