PDA

View Full Version : Solved: Getting error "Run Time error 462"



Nolanjt2
03-25-2010, 05:11 PM
Using MSAccess code to control a Word document and am getting this 462 error when the line above works and the lines about 5 lines down work all within a with-endwith code set.

Here are the code extracts:

Dim objApp As Word.Application
Dim objWord As Word.Document
Set objApp = New Word.Application
Set objWord = objApp.Documents.Open (FileName:="\\ftp\cvic\Crap.txt (file://\\ftp\cvic\Crap.txt)", Encoding:=Western)

objApp.Visible = True
objWord.Activate

objApp.ActiveDocument.PageSetup.LineNumbering.Active = False
objApp.ActiveDocument.PageSetup.Orientation = wdOrientPortrait

'Works to here

'following does not work - run time error 462

objApp.ActiveDocument.PageSetup.TopMargin = InchesToPoints(0.3)
objApp.ActiveDocument.PageSetup.BottomMargin = InchesToPoints(0.3)
objApp.ActiveDocument.PageSetup.LeftMargin = InchesToPoints(0.4)
objApp.ActiveDocument.PageSetup.RightMargin = InchesToPoints(0.4)
objApp.ActiveDocument.PageSetup.Gutter = InchesToPoints(0)
objApp.ActiveDocument.PageSetup.HeaderDistance = InchesToPoints(0.5)
objApp.ActiveDocument.PageSetup.FooterDistance = InchesToPoints(0.5)
objApp.ActiveDocument.PageSetup.PageWidth = InchesToPoints(8.5)
objApp.ActiveDocument.PageSetup.PageHeight = InchesToPoints(11)
objApp.ActiveDocument.PageSetup.OddAndEvenPagesHeaderFooter = False
objApp.ActiveDocument.PageSetup.DifferentFirstPageHeaderFooter = False
objApp.ActiveDocument.PageSetup.VerticalAlignment = wdAlignVerticalTop

'starts working again here
objApp.ActiveDocument.PageSetup.SuppressEndnotes = False
objApp.ActiveDocument.PageSetup.MirrorMargins = False

So what is it about the pagesetup am I missing?

Thanks.
Nolan

Nolanjt2
03-25-2010, 05:23 PM
Actually it starts working again at the Header odd even line. sorry.

Nolanjt2
03-25-2010, 05:37 PM
I've got it resolved. The Inches to points function must not be in the word libraries in my references. I converted them each to points and it sailed right through. Monday I will write a inches to points function.

Thanks for taking a look.