Word 2003 PIA - set layout to view print

  • Thread starter Scott Gravenhorst
  • Start date
S

Scott Gravenhorst

I'm using VB 2008 Express Edition and Office 2003 PIA interop to
modify a word document.

I need to be able to force the document into View - Print Layout
before saving. Some forum research revealed this:

wordApp.ActiveWindow.View = WdViewType.wdPrintView

This was posted by an MVP, but the compiler delares that .View is read
only.

Unfortunately, I did not see whether this info is for Office 2003 PIA
or VB 2008.

Is what I need to do possible? If so, how?

Thanks in advance,

-- ScottG
 
S

Shauna Kelly

Hi Scott

The .View property is not, normally, read-only.

1. Check that there really is an ActiveWindow. Word does not necessarily
have an ActiveWindow all the time.

2. Try code like the following (which is what the MacroRecorder gives
you if you record changing views):

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

You'll need to qualify the objects and the enumeration appropriately
for your code, of course.

Hope this helps.

Shauna Kelly. Microsoft MVP.
http://www.shaunakelly.com/word
 
S

Scott Gravenhorst

Shauna,

Thank you very much, that worked - mostly, the view switches to print
layout, but because I had executed a search/replace with a .Find in
the header object, the little header/footer toolbar remains open - I'm
sure there's a way to close that, I assume I would call a .Close()
method, but on what object?

Thanks again, that was very helpful.
 
S

Shauna Kelly

Hi Scott

If you have moved the selection to the header or footer area, and now
wish to select the main body of the document, one option is
docMyDoc.Range(0,0).Select
where docMyDoc is a reference to your document of interest.

Hope this helps.

Shauna Kelly. Microsoft MVP.
http://www.shaunakelly.com/word
 
S

Scott Gravenhorst

Hi Shauna,

Again, thanks, you are correct about what I did with the selection and
that works perfectly.

You have a great day!
 

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