Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Word object model problems + multi tray printing

Status
Not open for further replies.

AndyG75

Programmer
Nov 17, 2000
4
GB
Can you help?

I'm trying to use the word object model through VB to select the paper trays onto which a word document should be printed. This is done by accessing the .FirstPageTray and .OtherPagesTray properties of the ActiveDocument's PageSetup object.

The above works fine most of the time, however the documents I'm trying to print are protected, and often contain framed paragraphs.

To access the PageSetup object through code, the document must first be unprotected. However, when you unprotect the document a frame can end up being selected which renders the PageSetup object inaccessible (also even when you do the process manually in Word).

I've tried using lines of code like
oWord.Selection.MoveDown Unit:=wdLine, Count:=1
in an attempt to unselect the frame. The above works when you actually look at Word (i.e. it makes the page setup option accessible), but the code still gives the same problem.

The actual error message is:

"This method or property is not available because the object refers to a framed paragraph."

which occurs when the following line of code is run:

".PageSetup.FirstPageTray = wdPrinterDefaultBin"

Anybode any ideas? Here's the code I'm using anyway...

Private Sub Command1_Click()
Dim oWord As New Word.Application

oWord.Documents.Open "C:\TEST.DOC"
oWord.Visible = True

With oWord.ActiveDocument
.Unprotect "Password"
.PageSetup.FirstPageTray = wdPrinterDefaultBin
.PageSetup.OtherPagesTray = wdPrinterDefaultBin
.Close
End With

oWord.Quit
End Sub

THANKS FOR READING!! Hope you can help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top