Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
specialcells(xlLastCell) and method global range error
I have an excel file that I want to manipulate from within Access.
Access creates the file, changes the formatting, saves it then emails it as an attachment. I've added the following code to the section that changes the formatting: With oExcel.Worksheets("compliance export qry") ..Range(Range("A1"), ActiveCell.SpecialCells(xlLastCell)).Select End With With Selection.Interior ..ColorIndex = 2 ..Pattern = xlSolid End With Selection.Borders(xlDiagonalDown).LineStyle = xlNone Selection.Borders(xlDiagonalUp).LineStyle = xlNone With Selection.Borders(xlEdgeLeft) '.LineStyle = xlContinuous ..LineStyle = xlNone '.Weight = xlThin '.ColorIndex = xlAutomatic End With With Selection.Borders(xlEdgeTop) '.LineStyle = xlContinuous '.Weight = xlThin '.ColorIndex = xlAutomatic ..LineStyle = xlNone End With With Selection.Borders(xlEdgeBottom) '.LineStyle = xlContinuous '.Weight = xlThin '.ColorIndex = xlAutomatic ..LineStyle = xlNone End With With Selection.Borders(xlEdgeRight) '.LineStyle = xlContinuous '.Weight = xlThin '.ColorIndex = xlAutomatic ..LineStyle = xlNone End With With Selection.Borders(xlInsideVertical) '.LineStyle = xlContinuous '.Weight = xlThin '.ColorIndex = xlAutomatic ..LineStyle = xlNone End With With Selection.Borders(xlInsideHorizontal) '.LineStyle = xlContinuous '.Weight = xlThin '.ColorIndex = xlAutomatic ..LineStyle = xlNone End With to set the page white. It works fine if I run it once but if I run it twice in a row I get a Method Global Object Range failed error. Any ideas what this error is and how to fix it? Thanks |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
runtime error 1004 method range of object global failed | Excel Programming | |||
SpecialCells(xlLastCell) | Excel Programming | |||
Runime Error 1004 Method Range of Object Global Failed | Excel Programming | |||
.SpecialCells(xlLastCell).Select | Excel Programming | |||
XP VBA: Range("A2", ActiveCell.SpecialCells(xlLastCell)).Select | Excel Programming |