Changing Views in Word with VBA

S

srfdggy5

Hello... How can change the view from outline to Print Layout using VBA
I have some code that loads documents to a page and combines them.
But once that is done, I would like it to change to Print Layout vie
so it will be more familiar to the users of the form to enter thei
information. Any help would be greatly appreciated. Thanks agai
ahead of time. My last piece of code is as follows:

Public Sub MergeSubDocuments()
With ActiveDocument.Subdocuments
Do While .Count > 0
Merge .Item(1)
Loop
End With
End Su
 
J

J. Verdaasdonk

Hi,

Trie this in you're code:

Code
-------------------
If ActiveWindow.View.SplitSpecial = wdPaneNone Then
ActiveWindow.ActivePane.View.Type = wdPrintView
Else
ActiveWindow.View.Type = wdPrintView
End If
 
S

srfdggy5

Thanks for the info... Well, I placed it in my code, and unfortunatel
it is not changing the view to print preview. This really has m
baffled. Here is what it looks like now with the code, but it stil
leaves it in outline view...

Public Sub MergeSubDocuments()
With ActiveDocument.Subdocuments
Do While .Count > 0
Merge .Item(1)
Loop
End With
If ActiveWindow.View.SplitSpecial = wdPaneNone Then
ActiveWindow.ActivePane.View.Type = wdPrintView
Else
ActiveWindow.View.Type = wdPrintView
End If
End Su
 
J

J. Verdaasdonk

Hi,

I'm not used to working with Master documents.
Have you tried leaving the Iff statement out en directly set th
windowstate:

Code
-------------------
Public Sub MergeSubDocuments()
With ActiveDocument.Subdocuments
Do While .Count > 0
Merge .Item(1)
Loop
End With
ActiveWindow.View.Type = wdPrintView
End Sub
 
S

srfdggy5

Well, I can get it to work when the document opens, but not when th
selected subdocuments are chosen and merged. It just wants to stay i
the Outline View for some reason
 
J

J. Verdaasdonk

Hi,

I'm Sorry I've got no MasterDocument with all you're code in it t
test.
Perhaps somewhere the focus to the ActiveDocument is Lost?

Try:
ActiveDocument.ActiveWindow.View.Type = wdPrintView

Like I said before I'm not using MasterDocuments at all. (I don't lik
working in them)

See Yah,
Joos
 

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