R
ragtopcaddy via OfficeKB.com
I have a line of code that works sporadically. When it doesn't work I get
"The remote server does not exist or is unavailable". I'm running this code
from an Access/VBA module, so I suspect the remote server in question is
Excel. Here's the code:
conRows = 28
With shtRpt
n = n + conRows
'Select the blank form at the end of the records and paste it
below itself,
'always leaving the last record blank in order to copy it to add
to the records
'until the last record is completed. Then use the last form for
the last record.
If i < nCount Then
.Range(.Cells(n - 27, 1), .Cells(n, conCols)).Select
XLobj.Selection.Copy
.Range(.Cells(n + 1, 1), .Cells(n + conRows, conCols)).Select
XLobj.Selection.Insert
XLobj.CutCopyMode = False
***************The following line generates the
error******************************************
ActiveWindow.SelectedSheets.HPageBreaks.Add Before:
=ActiveCell
XLobj.ActiveCell.Offset(-28, 0).Activate
Else
.Range(.Cells(n - 27, 1).Address).Activate
End If
When I examine the code, a cursor placed over the "ActiveCell" text shows the
tooltip:
ActiveCell <The remote server does not exist or is unavailable>
Sometimes the code runs just fine for all records, but sometimes it gets
stuck on this line.
Thanks for your help
Bill
--
Bill Reed
"If you can't laugh at yourself, laugh at somebody else"
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.aspx/excel-programming/200805/1
"The remote server does not exist or is unavailable". I'm running this code
from an Access/VBA module, so I suspect the remote server in question is
Excel. Here's the code:
conRows = 28
With shtRpt
n = n + conRows
'Select the blank form at the end of the records and paste it
below itself,
'always leaving the last record blank in order to copy it to add
to the records
'until the last record is completed. Then use the last form for
the last record.
If i < nCount Then
.Range(.Cells(n - 27, 1), .Cells(n, conCols)).Select
XLobj.Selection.Copy
.Range(.Cells(n + 1, 1), .Cells(n + conRows, conCols)).Select
XLobj.Selection.Insert
XLobj.CutCopyMode = False
***************The following line generates the
error******************************************
ActiveWindow.SelectedSheets.HPageBreaks.Add Before:
=ActiveCell
XLobj.ActiveCell.Offset(-28, 0).Activate
Else
.Range(.Cells(n - 27, 1).Address).Activate
End If
When I examine the code, a cursor placed over the "ActiveCell" text shows the
tooltip:
ActiveCell <The remote server does not exist or is unavailable>
Sometimes the code runs just fine for all records, but sometimes it gets
stuck on this line.
Thanks for your help
Bill
--
Bill Reed
"If you can't laugh at yourself, laugh at somebody else"
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.aspx/excel-programming/200805/1