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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VbScript Word formatting problem 1

Status
Not open for further replies.

TrevJones

Programmer
Nov 20, 2000
37
GB
I am trying to use the following code to open and format a word document but it fails with
Microsoft VBScript runtime error: Type mismatch: 'InchesToPoints'

I have no idea what is wrong with the code which uses word97

Dim appWord
Set appWord = CreateObject("Word.Application")
appWord.Visible = True

appWord.Documents.Open("d:\wsh\testout.doc")

strName = appWord.ActiveDocument.Name
strPath = appWord.ActiveDocument.Path & "\"

With appWord.ActiveDocument.PageSetup
.LineNumbering.Active = False
.Orientation = .92
.TopMargin = InchesToPoints(1)
.BottomMargin = 1
.LeftMargin = 1
.RightMargin = 1
.Gutter = 1
.HeaderDistance = 0.5
.FooterDistance = 0.5
.PageWidth = 11
.PageHeight = 8.5
.FirstPageTray = wdPrinterDefaultBin
.OtherPagesTray = wdPrinterDefaultBin
.SectionStart = wdSectionNewPage
.OddAndEvenPagesHeaderFooter = False
.DifferentFirstPageHeaderFooter = False
.VerticalAlignment = wdAlignVerticalTop
.SuppressEndnotes = False
.MirrorMargins = False
End With

I would be grateful for any help

Cheers
 
It appears that InchestoPoints is a user defined function that is missing from the code. Is this a portion of code that was extracted from a larger example? If so, look within the original code for a user defined function by that name and add it to the script.
 
The InchesToPoints as far as I can tell are part of word document pagesetup object. I can't see any difference in this code to examples I have seen on the web.
 
Have you tried this ?
.TopMargin = appWord.InchesToPoints(1)

Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884
 
Thanks very much, that solved the InchesToPoints problem. There are still other issues but i'm very nearly there. Thanks for putting me in the picture
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top