Effect of displaying application

V

Vivien Parlat

Hello,

I'm facing a problem in a Word macro.
I'm developing a macro which modifies the header and footer of all
documents in a folder, according to a reference template.
My vba macro is opening each file, and does this:

For Each aSection In aDocument.Sections
For Each aHF In aSection.Headers
If aHF.Range.StoryType = wdPrimaryHeaderStory Then
tplSection.Headers(wdHeaderFooterPrimary).Range.Copy
aHF.Range.Paste
End if
' the same with other Storytypes
Next aHF
Next aSection

The problem is the following:
In debug, everything works fine. But when running the macro, in some
modified documents the images in the header are not displayed and are
replaced by a white rectangle with a small red cross (x).
To correct this I set aDocument.Application.Visible = True, but
windows are flickering.

Could someone give me an idea or an explanation for the documents
change to be different depending on Word is visible or not ? And how
to make it run fine when Word is not displayed ?

Thank you in advance for any help(and sorry for my bad English)
 

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