tomtraxler
May 7th, 2005, 06:40 AM
I am trying to export some calculations to a table in a Word document. When I run the following code, it works fine in Word 2003, but I get an error message when I run it on a computer using Word 97, although my References use Word 11.0 Object Library.
The error message says that it is Runtime Error 48, Error Loading DLL.
Here is the code:
-----------------------------------------------------------------
Public Sub XYZ ()
Dim objWord as Object
Dim objDoc As Object
Set objWord = CreateObject("word.application")
Set objDoc = objWord.Documents.Add
objWord.Visible = True
objDoc.Activate
With objDoc.ActiveWindow.Selection
objDoc.Tables.Add Range:=.Range, NumRows:=26, NumColumns _
:=4
.Tables(1).AutoFormat Format:=wdTableFormatSimple1, ApplyBorders _
:=True, ApplyShading:=True, ApplyFont:=True, ApplyColor:=True, _
ApplyHeadingRows:=True, ApplyLastRow:=True, ApplyFirstColumn:=True, _
ApplyLastColumn:=False, AutoFit:=True
.SelectColumn
.Cells.SetWidth ColumnWidth:=InchesToPoints(2.5), RulerStyle:= _
wdAdjustNone
...
-----------------------------------------------------------------
The error occurs on the last line ".Cells.SetWidth ColumnWidth:=InchesToPoints(2.5), RulerStyle:= _
wdAdjustNone"
All i am trying to do is to select this first column and change its width to 2.5", but i can't get this fixed.
I sure would appreciate any help you could give me.
I am trying to export some calculations to a table in a Word document. When I run the following code, it works fine in Word 2003, but I get an error message when I run it on a computer using Word 97, although my References use Word 11.0 Object Library.
The error message says that it is Runtime Error 48, Error Loading DLL.
Here is the code:
-----------------------------------------------------------------
Public Sub XYZ ()
Dim objWord as Object
Dim objDoc As Object
Set objWord = CreateObject("word.application")
Set objDoc = objWord.Documents.Add
objWord.Visible = True
objDoc.Activate
With objDoc.ActiveWindow.Selection
objDoc.Tables.Add Range:=.Range, NumRows:=26, NumColumns _
:=4
.Tables(1).AutoFormat Format:=wdTableFormatSimple1, ApplyBorders _
:=True, ApplyShading:=True, ApplyFont:=True, ApplyColor:=True, _
ApplyHeadingRows:=True, ApplyLastRow:=True, ApplyFirstColumn:=True, _
ApplyLastColumn:=False, AutoFit:=True
.SelectColumn
.Cells.SetWidth ColumnWidth:=InchesToPoints(2.5), RulerStyle:= _
wdAdjustNone
...
-----------------------------------------------------------------
The error occurs on the last line ".Cells.SetWidth ColumnWidth:=InchesToPoints(2.5), RulerStyle:= _
wdAdjustNone"
All i am trying to do is to select this first column and change its width to 2.5", but i can't get this fixed.
I sure would appreciate any help you could give me.
I am trying to export some calculations to a table in a Word document. When I run the following code, it works fine in Word 2003, but I get an error message when I run it on a computer using Word 97, although my References use Word 11.0 Object Library.