E
Ed from AZ
With Excel and Word 2003, I'm using Excel VBA to automate a Word
document. Everything is going pretty much okay so far - except I keep
getting a Runtime 462 error - Remote server not available.
First, all this is on my own machine - there are no remote servers
involved.
Second, I did do some searching and found that this can crop up when
an object - like "range" - is not specifically declared as belonging
to either Word or Excel. So VB will choose, and may choose
incorrectly. So I went back and made sure everything involved here
was declared to an application.
Immediately before the error, I set a Word range and an Excel range,
and copy the Excel rnage into the Word doc as a table. That works
fine. Then I set an object to the table in Word and try to manipulate
it. That's when it errors.
If anyone can help me out. I would appreciate it.
Ed
Set wdRng = doc.Bookmarks("XL1").Range
wdRng.MoveEnd wdParagraph, 1
wdRng.Collapse wdCollapseEnd
Set rng = wks.Range("A2:H30")
rng.Copy
wdRng.InsertBefore Chr(13)
wdRng.Collapse wdCollapseEnd
wdRng.Paste
Set tbl = wdRng.Tables(1)
' NOTE: tbl is Dim'd as Word.Table
With tbl
.TopPadding = InchesToPoints(0.01) '*****
' When stepping through with F8, it errors when I get
' to the .TopPadding line
.BottomPadding = InchesToPoints(0.01)
.LeftPadding = InchesToPoints(0.02)
.RightPadding = InchesToPoints(0.02)
.Spacing = 0
.AllowPageBreaks = True
.AllowAutoFit = False
.Rows.Alignment = wdAlignRowCenter
.Rows.AllowBreakAcrossPages = False
.Range.Cells.VerticalAlignment = wdCellAlignVerticalCenter
.Rows.SpaceBetweenColumns = InchesToPoints(0.04)
.Rows.Height = wdRowHeightAuto
End With
document. Everything is going pretty much okay so far - except I keep
getting a Runtime 462 error - Remote server not available.
First, all this is on my own machine - there are no remote servers
involved.
Second, I did do some searching and found that this can crop up when
an object - like "range" - is not specifically declared as belonging
to either Word or Excel. So VB will choose, and may choose
incorrectly. So I went back and made sure everything involved here
was declared to an application.
Immediately before the error, I set a Word range and an Excel range,
and copy the Excel rnage into the Word doc as a table. That works
fine. Then I set an object to the table in Word and try to manipulate
it. That's when it errors.
If anyone can help me out. I would appreciate it.
Ed
Set wdRng = doc.Bookmarks("XL1").Range
wdRng.MoveEnd wdParagraph, 1
wdRng.Collapse wdCollapseEnd
Set rng = wks.Range("A2:H30")
rng.Copy
wdRng.InsertBefore Chr(13)
wdRng.Collapse wdCollapseEnd
wdRng.Paste
Set tbl = wdRng.Tables(1)
' NOTE: tbl is Dim'd as Word.Table
With tbl
.TopPadding = InchesToPoints(0.01) '*****
' When stepping through with F8, it errors when I get
' to the .TopPadding line
.BottomPadding = InchesToPoints(0.01)
.LeftPadding = InchesToPoints(0.02)
.RightPadding = InchesToPoints(0.02)
.Spacing = 0
.AllowPageBreaks = True
.AllowAutoFit = False
.Rows.Alignment = wdAlignRowCenter
.Rows.AllowBreakAcrossPages = False
.Range.Cells.VerticalAlignment = wdCellAlignVerticalCenter
.Rows.SpaceBetweenColumns = InchesToPoints(0.04)
.Rows.Height = wdRowHeightAuto
End With