setting page size to Legal in word2k

J

jridgway

Hello all,

I've been tasked with converting UNIX documents to PDF. For the most
part, all is working just fine. Most docs are processed correctly and
use the standard paper size (letter). It came to my attention last
week that I needed to format certain docs to use paper size (Legal).

I have tried all sorts of combinations to get word to do this
programmatically, without success. I have searched and tried many
solutions provided here and none have provided the answer.

I have included the code below responsible for the formatting of the
word doc as it is being processed.


Set WDoc = CreateObject("Word.Application")
With WDoc
'.Visible = False
.Visible = True
'.Activate
.Documents.Open sDoc
.ActiveDocument.PageSetup.Orientation = 1
.ActiveDocument.PageSetup.PageSize(wdPaperLegal) <---- Current
attempt

'if htmlReportNum = "D004_D_BECPB" then

'.ActiveDocument.PageSetup.PageSize = wdPaperLegal <----Other
attempts

'For each sec in ActiveDocument.Sections
'sec.PageSetup.PaperSize(wdPaperLegal) <----Other attempts
'Next


'ActiveDocument.PageSetup.PageWidth = 14 <----Other attempts
'ActiveDocument.PageSetup.PageHeight = 8.5 <----Other attempts
'.pagesize=wdPaperLegal <----Other attempts

'else

'ActiveDocument.PageSetup.PageWidth = InchesToPoints(11)
'ActiveDocument.PageSetup.PageHeight = InchesToPoints(8.5)

'.ActiveDocument.PageSetup.PaperSize = wdPaperLetter

'end if

if htmlReportNum = "D004_D_BECPB" then
WScript.Echo htmlReportNum
end if

.ActiveDocument.PrintOut(False)
'.ActiveDocument.PrintOut(True)
'.Options.PrintBackGround = False
.ActiveDocument.Close
.Application.Quit
End With
Set WDoc=Nothing



With all of these attempts, no error is reported indicating that my
attempt to choose a paper size is invalid.

Thanks for any help you may be able to provide.
 
J

Jonathan West

Hi jridgeway

It looks like you are claling Word by late binding, and therefore your VB
program probably has no means of knowing the value of the constant
wdPaperLegal

Its value is 4, so try replacing wdPaperLegal with 4 and see if that helps.
 

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

Similar Threads


Top