Word 2007 View

G

Greg Maxey

When I use VBA to access one of the header or footer storyranges from the
main storyrange, the view allows switches from PrintView to Draft.

For example if the IP is in the maintext story and I run this code the
header text will be selected but the view will shift to Draft..

Sub Test()
ActiveDocument.StoryRanges(7).Select
End Sub

Does anyone know how to prevent this shift in view?

Thanks.
 
J

Jay Freedman

When I use VBA to access one of the header or footer storyranges from the
main storyrange, the view allows switches from PrintView to Draft.

For example if the IP is in the maintext story and I run this code the
header text will be selected but the view will shift to Draft..

Sub Test()
ActiveDocument.StoryRanges(7).Select
End Sub

Does anyone know how to prevent this shift in view?

Thanks.

This thing sucks rocks.

I don't know how to prevent the switch to Draft -- it seems to insist
on opening the Header pane, even though it's nearly impossible to get
to that pane from the UI, requiring you to open the Macro dialog and
run the built-in command NormalViewHeaderArea.

But you can program an immediate switch back to PrintView, even though
it flickers a little:

Sub Demo()
On Error Resume Next ' in case header doesn't exist yet
ActiveDocument.StoryRanges(wdPrimaryHeaderStory).Select
ActiveWindow.View = wdPrintView
End Sub

But when the user closes the header area, the view switches back to
Draft again! You just can't win.
 
G

Greg Maxey

Jay,

Yes, I already experienced all the other issues you mention. I thought I
would bypass all those details and just ask for a way to stop the nightmare
;-).
 
J

Jonathan West

Greg Maxey said:
Jay,

Yes, I already experienced all the other issues you mention. I thought I
would bypass all those details and just ask for a way to stop the
nightmare ;-).

Sounds as if the only way to avoid the nightmare is not to Select the header
in the first place.

But if you have to select it, have you tried an alternative approach such as
ActiveDocument.Sections(1).Headers(wdHeaderFooterPrimary).Range.Select

(I don't have 2007 loaded on the machine I'm writing from so can't test this
myself)
 
G

Greg Maxey

Jonathan,

Yes, I have tried every approach that I can think of and you suggestion
numbers among the few.

I concede that my frustration is tied to my own insistence to select the
text. I am playing around with some code that allows a user to evaluate
each spelling error and choose to let it stand or suppress the proofing. The
procedure selects and brings the error into view and displays a userform
that provides the options. Here is a snippet of the code.

..............
Set oRngCurrent = myErrors(1)
If myErrors.Count > 0 Then
myErrors(1).NoProofing = True
On Error Resume Next
If oRngCurrent.Start = myErrors(1).Start Then
Do
oRngCurrent.MoveStart wdCharacter, -1
oRngCurrent.NoProofing = True
Loop While oRngCurrent.End = myErrors(1).End
End If
On Error GoTo 0
End If
Next_Pass:
If myErrors.Count > 0 Then
ActiveWindow.ScrollIntoView myErrors(1)
myErrors(1).Select
...................

When the procedure finishes with the maintext and textframe stories, it
procedes to the headers and footers. When that happens the sceen shifts to
Draft. So if there is not way to avoid the shift on "Selection" can you
offer an alternative process of bringing the text into view and highlighting
it for the user?
 
J

Jay Freedman

Sounds as if the only way to avoid the nightmare is not to Select the header
in the first place.

But if you have to select it, have you tried an alternative approach such as
ActiveDocument.Sections(1).Headers(wdHeaderFooterPrimary).Range.Select

(I don't have 2007 loaded on the machine I'm writing from so can't test this
myself)


--
Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup

Hi Jonathan,

That alternative behaves exactly the same way. :-(
 
J

Julian

I know this is going to sound stupid because there is no justification for
it, but I had something vaguely similar that related to the Reviewing Pane
in Word 2002/XP when messing with comments (RP also often pops up when you
don't want it to), but you *could* try taking a copy of the range of
interest as a duplicate and selecting that... might be only a <5% chance but
maybe worth a go if nothing else has worked...

Apologies if it turns out to be a complete waste of time....

Julian
 
T

Tony Jollans

It is rather bizarre, isn't it?

You could always use some of the guff the macro recorder generates when you
record switching to header view. This seems to work:

If ActiveWindow.ActivePane.View.Type = wdPrintView Then _
ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
ActiveDocument.StoryRanges(7).Select
 

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