Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
runtime error 1004 method range of object global failed dreamz[_26_] Excel Programming 3 January 26th 06 07:23 PM
SpecialCells(xlLastCell) José Ignacio Bella Excel Programming 12 January 9th 05 07:20 PM
Runime Error 1004 Method Range of Object Global Failed Mohan[_5_] Excel Programming 3 May 21st 04 03:35 PM
.SpecialCells(xlLastCell).Select jim c. Excel Programming 3 October 3rd 03 04:02 PM
XP VBA: Range("A2", ActiveCell.SpecialCells(xlLastCell)).Select wessman Excel Programming 2 July 23rd 03 06:33 PM


All times are GMT +1. The time now is 11:52 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"