Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 23
Default .selection.find not working via automation

I have an access database that creates a report in XL via automation.
I have this code that is not working:

<<Snip
Set XL = New Excel.Application
With XL

.Visible = True 'debugging only
.Workbooks.Add

i = rs.Fields.Count - 1

'Header row
For x = 0 To i
.Cells(1, x + 1).Value = rs(x).Name
Next x

'Detail
.Range("A2").CopyFromRecordset rs

'format it

'Remove 'Limiter columns
On Error Resume Next
Do
.Range("1:1").Select
.Selection.Find(What:="limiter", After:=ActiveCell,
LookIn:=xlValues, _
LookAt:=xlPart, SearchOrder:=xlByRows,
SearchDirection:=xlNext, _
MatchCase:=False,
SearchFormat:=False).EntireColumn.Delete
If Err.Number < 0 Then Exit Do
Loop
On Error GoTo cmdOpenReport_Click_ErrHandle
<<Snip

The .selection.find is not finding the text 'limiter'. Howerver if I
run that section of the code in the excel immediate window it works
fine.

Any ideas?

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,452
Default .selection.find not working via automation

You are doing .Cells .Range .Selection etc. but these
are properties of a worksheet not of the Excel application.
So you will have to fully qualify the worksheet and do something like this:

Dim XL As Excel.Application
Dim XLBook As Workbook
Dim XLSheet As Worksheet

Set XL = New Excel.Application
Set XLBook = XL.Workbooks.Add
Set XLSheet = XLBook.ActiveSheet

With XLSheet

For x = 0 To i
.Cells(1, x + 1).Value = rs(x).Name
Next x

etc.


RBS


"Bill Schanks" wrote in message
oups.com...
I have an access database that creates a report in XL via automation.
I have this code that is not working:

<<Snip
Set XL = New Excel.Application
With XL

.Visible = True 'debugging only
.Workbooks.Add

i = rs.Fields.Count - 1

'Header row
For x = 0 To i
.Cells(1, x + 1).Value = rs(x).Name
Next x

'Detail
.Range("A2").CopyFromRecordset rs

'format it

'Remove 'Limiter columns
On Error Resume Next
Do
.Range("1:1").Select
.Selection.Find(What:="limiter", After:=ActiveCell,
LookIn:=xlValues, _
LookAt:=xlPart, SearchOrder:=xlByRows,
SearchDirection:=xlNext, _
MatchCase:=False,
SearchFormat:=False).EntireColumn.Delete
If Err.Number < 0 Then Exit Do
Loop
On Error GoTo cmdOpenReport_Click_ErrHandle
<<Snip

The .selection.find is not finding the text 'limiter'. Howerver if I
run that section of the code in the excel immediate window it works
fine.

Any ideas?


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
C#/Excel automation add-in not working on MediaCenter? My interest Excel Programming 5 January 28th 07 02:11 PM
Automation Error: The system cannot find file specified Shilpa[_2_] Excel Programming 3 August 25th 06 09:05 AM
where do I find docs on excel automation programming? Mike[_108_] Excel Programming 0 June 8th 06 06:41 PM
Word Automation - Find/Replace JMB Excel Discussion (Misc queries) 2 May 21st 05 10:34 PM
OLE automation - use of .selection Richard Abrahams Excel Programming 1 September 11th 04 08:01 PM


All times are GMT +1. The time now is 12:29 PM.

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

About Us

"It's about Microsoft Excel"