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

Tip: Looking for answers? Try searching our database.

View Frustrations

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Greg Maxey - 17 Oct 2005 03:47 GMT
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

Signature

Greg Maxey/Word MVP
See:
http://gregmaxey.mvps.org/word_tips.htm
For some helpful tips using Word.

Jean-Guy Marcil - 17 Oct 2005 14:51 GMT
Greg Maxey was telling us:
Greg Maxey nous racontait que :

> Sub Frustration()
> ActiveDocument.Bookmarks("Test").Select
[quoted text clipped - 22 lines]
> 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.

Signature

Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarcilREMOVE@CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org 

Greg - 17 Oct 2005 17:57 GMT
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

Rate this thread:






 
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.