I don't know what's wrong. I did check before I posted (I can't remember
exactly what I did) but can''t make it work now.
However, one of the zero windows, it seems, is the active window, and this
appears to work - except that the window has no caption - and still isn't
included in the collection..
Sub Makro1()
Dim oDcm As Document
Set oDcm = Documents.Add(Visible:=False)
oDcm.Range.Text = "xxxxxxxxxxxxxx"
MsgBox oDcm.Windows.Count ' = 0
' understandable as there is no window yet
' oDcm.Windows(1).Visible = True 'results in error 5941
oDcm.ActiveWindow.Visible = True ' seems to work
'oDcm.Windows.Add
'oDcm.Windows(1).Visible = True ' ok so far
' but now oDcm has 2 (!) windows
MsgBox oDcm.Windows.Count ' still 0 ????
End Sub
--
Enjoy,
Tony
> Hi Tony,
>
[quoted text clipped - 18 lines]
> "red.sys" & chr(64) & "t-online.de"
> Word 2002, Windows 2000
Helmut Weber - 31 Jan 2006 16:47 GMT
Hi Tony,
there is a mistake in the comments in my code.
After adding a window, to an unvisible document,
which has a windows.count of zero,
the document has a windows count of 2.
Dim oDcm As Document
Set oDcm = Documents.Add(Visible:=False)
oDcm.Range.Text = "xxxxxxxxxxxxxx"
MsgBox oDcm.Windows.Count ' = 0
oDcm.Windows.Add
MsgBox oDcm.Windows.Count ' = 2

Signature
Greetings from Bavaria, Germany
Helmut Weber, MVP WordVBA
Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"
Tony Jollans - 31 Jan 2006 17:26 GMT
Hi Helmut,
I thought your comment was correct to start with - are you just looking at
my changes to it?
Sub Makro1()
Dim oDcm As Document
Set oDcm = Documents.Add(Visible:=False)
oDcm.Range.Text = "xxxxxxxxxxxxxx"
MsgBox oDcm.Windows.Count ' = 0
oDcm.ActiveWindow.Visible = True ' seems to work
MsgBox oDcm.Windows.Count ' still 0 ????
End Sub
This just has to be a bug. I'm not sure whether an invisible document ought
to have an invisible window or not but I am sure any window it does have
should be in the windows collection.
This version seems to work round the problem ..
Sub Makro1()
Dim oDcm As Document
Set oDcm = Documents.Add(Visible:=False)
oDcm.Range.Text = "xxxxxxxxxxxxxx"
MsgBox oDcm.Windows.Count ' = 0
oDcm.Windows.Add.Close
MsgBox oDcm.Windows.Count ' now it's 'correct'
oDcm.Windows(1).Visible = True ' now it works
End Sub
--
Enjoy,
Tony
> Hi Tony,
>
[quoted text clipped - 17 lines]
> Win XP, Office 2003
> "red.sys" & Chr$(64) & "t-online.de"
Helmut Weber - 31 Jan 2006 18:22 GMT
Hi Tony,
>This just has to be a bug.
Right.
That's want I wanted to have confirmened.
Your workaround is working.

Signature
Greetings from Bavaria, Germany
Helmut Weber, MVP WordVBA
Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"