View Frustrations

G

Greg Maxey

Sub Frustration()
ActiveDocument.Bookmarks("Test").Select
"&^$%#*& view changes to Normal with Split window for header pane.
'The bookmark is selected.

'This bit gets the PrintView back but the selection is collapsed
If ActiveWindow.View.SplitSpecial <> wdPaneNone Then
ActiveWindow.Panes(2).Close
End If
ActiveWindow.ActivePane.View.Type = wdPrintView
ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader

'So I cobbled together this bit which is working. Question - Is there
'a way to "prevent" the view from changing when using the
..Bookmarks(index).Select
'method?
Dim myRng As Range
ActiveDocument.Bookmarks("Test").Select
Set myRng = Selection.Range
If ActiveWindow.View.SplitSpecial <> wdPaneNone Then
ActiveWindow.Panes(2).Close
End If
ActiveWindow.ActivePane.View.Type = wdPrintView
ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
myRng.Select
End Sub
 
J

Jean-Guy Marcil

Greg Maxey was telling us:
Greg Maxey nous racontait que :
Sub Frustration()
ActiveDocument.Bookmarks("Test").Select
"&^$%#*& view changes to Normal with Split window for header pane.
'The bookmark is selected.

'This bit gets the PrintView back but the selection is collapsed
If ActiveWindow.View.SplitSpecial <> wdPaneNone Then
ActiveWindow.Panes(2).Close
End If
ActiveWindow.ActivePane.View.Type = wdPrintView
ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader

'So I cobbled together this bit which is working. Question - Is there
'a way to "prevent" the view from changing when using the
.Bookmarks(index).Select
'method?
Dim myRng As Range
ActiveDocument.Bookmarks("Test").Select
Set myRng = Selection.Range
If ActiveWindow.View.SplitSpecial <> wdPaneNone Then
ActiveWindow.Panes(2).Close
End If
ActiveWindow.ActivePane.View.Type = wdPrintView
ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
myRng.Select
End Sub

Although I do not see the behaviour you describe with
ActiveDocument.Bookmarks("Test").Select (Word 2003 SP2);
just a shot in the dark, have you tried
ActiveDocument.Bookmarks("Test").Range.Select
instead?

<Lightning strikes>


Oh, just realized that your bookmark was in the Header.. Duh!

Selecting something in the header/footer from VBA always "screw up" the
view.
May I ask why you are selecting it instead of just working with the range
object?
I have never seen a case where I had to select stuff in a header as opposed
to just defining a range object.

--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 
G

Greg

JGM,

Well I am not quite ready to reveal the fruits of my grand
discombobulating efforts over the weekend to create a bookmark add-in
;-). Basically I want to use selection so a user can step through a
document view each bookmark.

I have mashed together the following which seems to keep thing is order
;-)

Sub Test()
Dim myRng As Range
Dim oViewOption As Long
oViewOption = 3 'Chage to 1 or 5 or 6 to test other Word2000 view
options
ActiveDocument.Bookmarks("Test1").Select
Set myRng = Selection.Range
Select Case oViewOption
Case 3 'Is = 3 'PrintView
With ActiveWindow
If .View.SplitSpecial <> wdPaneNone Then
.Panes(2).Close
.ActivePane.View.Type = oViewOption
.ActivePane.View.SeekView = wdSeekCurrentPageHeader
myRng.Select
End If
End With
Case 1 'Normal View
With ActiveWindow
If myRng.StoryType = 1 Or 5 Then
If .View.SplitSpecial <> wdPaneNone Then
.Panes(2).Close
End If
.ActivePane.View.Type = oViewOption
myRng.Select
End If
End With
Case 5 'Outline View
With ActiveWindow
If myRng.StoryType = 1 Or 5 Then
If .View.SplitSpecial <> wdPaneNone Then
.Panes(2).Close
End If
If Not myRng.StoryType = 5 Then
.ActivePane.View.Type = oViewOption
myRng.Select
End If
End If
End With
Case 6 'Is = 6 'Web View
With ActiveWindow
If myRng.StoryType = 1 Or 2 Or 3 Then
If .View.SplitSpecial <> wdPaneNone Then
.Panes(2).Close
End If
.ActivePane.View.Type = oViewOption
myRng.Select
End If
End With
Case Else
'Do Nothing
End Select
End Sub
 

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