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 / June 2005

Tip: Looking for answers? Try searching our database.

Macro behaves different when application is visible and when it isn't

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Ebbe - 19 Jun 2005 22:51 GMT
Hi

I have discovered that the behavior of macros is different when
Application.Visible = True and it is False.

I observed some problems when running the macro. I turned the
Application.Visible = True, debugged the code, corrected the errors, ran
some tests without debug, but still with Application.Visible = True.

As soon I changed Application.Visible = False, the resulting document, the
macro generated looked different.

How can I see follow thr progress in the document, as I step through
statements without having Application.Visible = True?

Are there some spicific behavior, that is different when Application.Visible
= True and Application.Visible = False (exept that the document is/is not
visible)?

In my examble I want the next page to have a new set of headers.
Standing at end of the document (end of page x) I use the following code:

Selection.InsertBreak Type:=wdSectionBreakNextPage

' Cut link between herder/footer on page x and page x+1
ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
Selection.HeaderFooter.LinkToPrevious = False
ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument

' Delete all contense in herder of page x+1
ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
Selection.WholeStory
Selection.Delete Unit:=wdCharacter, Count:=1
ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument

When Application.Visible = True, I have headers on page x and no headers on
page x+1.
When Application.Visible = False, I have No headers on page x and no headers
on page x+1.

It looks like there is a difference in what header/footer I am standing in
after inserting a SectionBreakNextPage and then doing a
ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader.

Ebbe
Word Heretic - 20 Jun 2005 04:19 GMT
G'day Ebbe,

You are using the wrong objects. Dont use Selection and ActiveWindow,
deal with objects direct

Eg

ActiveDocument.Storyranges(whatever).Sections(n)

When Vis is off, there is no 'selection' per se so you get problems.

Steve Hudson - Word Heretic

steve from wordheretic.com (Email replies require payment)
Without prejudice

Ebbe reckoned:

>Hi
>
[quoted text clipped - 41 lines]
>
>Ebbe
Ebbe - 20 Jun 2005 22:31 GMT
Hi Steve

OK
It looks like that I am not able to use Macro recorder to help me in this
case, because it works upon the ActiveVindow in stead of ActiveDocument :-(

Is it possible for you to give me some more details of what you mean about
"ActiveDocument.Storyranges(whatever).Sections(n)"?

I am not experienced in working with header/footer in VBA.
When I am positioned at the end of the document, and I will introduce a new
page with a different header/footer.
How do I transcript my code to use ActiveDocument in stead of ActiveVindow ?

Ebbe

> G'day Ebbe,
>
[quoted text clipped - 62 lines]
>>
>>Ebbe
Word Heretic - 24 Jun 2005 04:05 GMT
G'day "Ebbe",

Load up Word, open the VBE (Alt+F11) and open the Object Browser (F2).
Select Document. Examine its children. Then examine the children of
those children. By doing this you will gain an understanding of the
Document Object Model (DOM).

If you are unsure of something like Storyranges(whatever), look up
storyranges in the help system for an explanation.

Steve Hudson - Word Heretic

steve from wordheretic.com (Email replies require payment)
Without prejudice

Ebbe reckoned:

>Hi Steve
>
[quoted text clipped - 78 lines]
>>>
>>>Ebbe
 
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.