Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / January 2006

Tip: Looking for answers? Try searching our database.

Invisible document

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Bo Hansson - 31 Jan 2006 07:47 GMT
If  I open a document in invisible mode, how do I then make it visible?

/BosseH
Tony Jollans - 31 Jan 2006 09:57 GMT
[DocumentReference].Windows(1).Visible = True

--
Enjoy,
Tony

> If  I open a document in invisible mode, how do I then make it visible?
>
> /BosseH
Helmut Weber - 31 Jan 2006 12:35 GMT
Hi Tony,

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.Windows.Add
oDcm.Windows(1).Visible = True ' ok so far
' but now oDcm has 2 (!) windows
MsgBox oDcm.Windows.Count ' = 2 ???
End Sub

What's wrong?

--
Greetings from Bavaria, Germany
Helmut Weber, MVP WordVBA
"red.sys" & chr(64) & "t-online.de"
Word 2002, Windows 2000
Tony Jollans - 31 Jan 2006 15:35 GMT
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"


Rate this thread:






 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.