I would recommend that if you want the macro to run correctly when
invisible, you avoid as far as possible the use of the following objects
- ActiveDocument
- Selection
- any Window object, including ActiveWindow
For the most part, you can avoid using the ActiveDocument, as follows. When
opening a document, using the following syntax
Dim oDoc As Document
Set oDoc = Documents.Open(FileName:=C:\test.doc")
After that, whenever you are in the habit of using ActiveDocument, you can
use oDoc instead.
Once you have a reference to oDoc, you can do the following to define a
range
Dim oRange as Range
Set oRange = oDoc.Range(0, 0)
Then you can do almost anything with oRange that you can do with Selection.
In addition, you can define as many Range objects as you want or need, and
use them all simultaneously. You can only have one Selection.
With regard to breaking the link between sections for the header and footer,
you don't need to use the Window objects or the Selection at all for this.
There are several ways to approach this but probably the simplest is as
follows. Assume that oRange is pointing to somewhere within the section
whose header and footer you want to unlink, proceed as follows
With oRange.Sections(1)
.Headers(wdHeaderFooterPrimary).LinkToPrevious = False
.Footers(wdHeaderFooterPrimary).LinkToPrevious = False
End With

Signature
Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
Keep your VBA code safe, sign the ClassicVB petition www.classicvb.org
> Hey
>
[quoted text clipped - 30 lines]
>
> Ebbe
ESH@edbgruppen.dk - 23 Jun 2005 10:06 GMT
Hey
I have decided NOT to run the application invisible.
It involves too many changes :-(
Instead I run the macros minimized.
Doing this, I have one little problem:
When I open a new document with:
Documents.Open FileName:=BaseDocumentFullName, ReadOnly:=True
ActiveWindow.WindowState = wdWindowStateMinimize
The document pops up for a secund before it is minimized.
Are there any way I can do a "open minimized" to avoid this short pop-up?
Ebbe
Jonathan West - 23 Jun 2005 10:57 GMT
> Hey
>
[quoted text clipped - 12 lines]
>
> Ebbe
Hi Ebbe
Try this
Application.Screenupdating = False
Documents.Open FileName:=BaseDocumentFullName, ReadOnly:=True
ActiveWindow.WindowState = wdWindowStateMinimize
Application.Screenupdating = True

Signature
Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
Keep your VBA code safe, sign the ClassicVB petition www.classicvb.org
ESH@edbgruppen.dk - 23 Jun 2005 12:08 GMT
Thank you Jonathan.
It didn't prevent the window to pop up, but it shortened the time it was
visible essentially.
Ebbe