LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Error when use find method in vb6

Hi all,

I have an excel file with a series of date values as column. Each day I
need to populate some data under an appropriate column.

Now I'm writting a programme to automate this. In order to locate the
location of the column I use the find method :

=========
Set XlsApp = New Excel.Application
XlsApp.Visible = False
Set WkBk = XlsApp.Workbooks.Open("C:\Temp\Daily.xls")
Set WkSh = WkBk.Worksheets(1)
Set Rng = WkSh.UsedRange

Rng.Select
sDate = Format(DTPSaleDate.Value, "DD/MM/YYYY")
Selection.Find(What:=sDate, After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False).Activate
iCol = ActiveCell.Column '<-- Use this location to populate data in
rows

'populate data ...

Set WkSh = Nothing
WkBk.Close True
XlsApp.Quit
Set XlsApp = Nothing
MsgBox "Done"
==========

There are 2 situation will generate error, and the message is :
91 - object variable or With block variable not set

First one is, if the date value is matched, works fine, but if I don't exit
the program and run for another day, it gives the above error.

The second one is, if the date value is Not matched, it gives the same
error.

I'm thinking it may be related to how I quit the excel app., however I the
codes seems OK to me, could you please tell me what's wrong?

Thanks!!!




 
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
date find using find method x taol Excel Programming 2 December 22nd 05 09:51 AM
Error Trapping the Find method big t Excel Programming 2 October 24th 05 01:39 PM
Using variables to make a date and using find method to find that. KyWilde Excel Programming 2 April 21st 05 09:43 PM
Find Method Garry Douglas Excel Programming 0 December 31st 04 02:31 AM
find method? CG Rosén Excel Programming 2 November 12th 03 10:30 AM


All times are GMT +1. The time now is 09:52 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"