document visibility

P

Pablo Cardellino

Hi,
I open three files as this one:

Set prefDoc = Documents.Open(FileName:=Environ("appdata") & "\Corretor
AOLP\BibPref_NovaOrt.txt", _
AddToRecentFiles:=False, Revert:=False, OpenAndRepair:=True,
Visible:=False)

the Visible:=False option is working, but not as I expected: a window is
open for each document, but the widow area remains empty; I mean, the
document isn't visible in fact, but its window is: no document or toolbars,
just the title bar, the windows borders and the gray empty area. I'd like to
open the documents in a really invisible way, to avoid annoying or worry the
the user with "strange" windows. Is it possible?

Thanks in advance,
 
C

Cindy M.

Hi Pablo,

Which version of Word? Is your code in a Word VBA macro, or something else?

FWIW, it's not possible to completely "hide" a Word document from the user, as
a document that causes problems could conceivably block Word from closing
correctly. Any document you open will be available through the listing under
the "Windows" command.

That said, I don't remember the behavior you describe, which is why it's
imperative to know the version of Word involved...
I open three files as this one:

Set prefDoc = Documents.Open(FileName:=Environ("appdata") & "\Corretor
AOLP\BibPref_NovaOrt.txt", _
AddToRecentFiles:=False, Revert:=False, OpenAndRepair:=True,
Visible:=False)

the Visible:=False option is working, but not as I expected: a window is
open for each document, but the widow area remains empty; I mean, the
document isn't visible in fact, but its window is: no document or toolbars,
just the title bar, the windows borders and the gray empty area. I'd like to
open the documents in a really invisible way, to avoid annoying or worry the
the user with "strange" windows. Is it possible?

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or reply
in the newsgroup and not by e-mail :)
 
P

Pablo Cardellino

Hi, Cindy,
thanks for your response.

The word version is 2003, and the code is within a word VBA module. It's a
template for an special kind of proofreading and contains a set of macros
and forms, and stores data in three txt files. The files are stored in the
project own folder within Application Data folder, and are not locked for
edition (since they are just plain text files), but the templates include
forms to do that, so it is not necessary for the user to see the files open.
It would be much more worth for him/her not to notice the files are open,
there's no need of that.

First of all I tried to store the files contents into vars, but it wasn't
possible, because the kind of string comparison VBA offers for string
variables is very limited. So I keep the files open for being able to use
Document, Rrange, Words, Characters, Cells, Rows and other objects,
specially Find. I think I can manage to close the files before a user input
is needed, and open them again when there are need of them (typically
immediatelly after the user clicks OK), but this will head to redundant
processing: if 50 words within the document requires the user decision, 50
times the application will need to open the files and convert its contents
into a table and perform the other needed processing.

Regards,

Pablo
 
J

Jay Freedman

Hi Pablo,

You can push a document window completely off the screen by setting its .Left
property to a large negative number. Then you don't have to worry about whether
it's "visible" (you can leave .Visible = True and avoid the problems that
sometimes occur when manipulating documents that are not visible).

Here's a quick demonstration:

Sub x()
Dim currDoc As Document
Dim testDoc As Document
Dim startwidth As Long, startleft As Long

Set currDoc = ActiveDocument
Set testDoc = Documents.Add

With testDoc.ActiveWindow
startwidth = .Width
startleft = .Left
.Width = 10
.Left = -200
End With

currDoc.Activate

MsgBox "testdoc is off screen." & vbCr & _
"Click OK to bring it back."

With testDoc.ActiveWindow
.Width = startwidth
.Left = startleft
End With

testDoc.Activate
End Sub

--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the newsgroup so all
may benefit.
 
P

Pablo Cardellino

Hi, Jay,

good trick, but I thought of just minimizing the document windows. Doesn't
it seem more suitable? In case of a crash an inexpert user won't be afraid
about those phantom buttons in the taskbar.

Thanks anyway, you all are really a great help.

Pablo
 

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