Xl Object Activation Problem

ChetShah
03-28-2003, 08:47 AM
Hi All,

I'm running a VB Routine which opens Excel Workbook and cleans the data for first sheet. I then close all excel objects like so:

XL.Quit
Set WB = Nothing
Set XL = Nothing

But i don't unload the objects and Excel remains visible in Task Manager

When i then open an Range Object in another routine i get VB Run Time Error 1004 - Method 'Range of Object' _Global Failed

Any ideas why this happens??

Chet

Wamphyri
03-28-2003, 08:52 AM
You've got objects in your code that are not referenced back to Excel.Application.
Could you post your code, so we can see which objects are not referenced properly.

ChetShah
03-28-2003, 08:56 AM
Here's some of the Code

Dim FileSpec As String
Dim FileRead As String
Dim NewFileSpec As String
Dim i As Integer
Dim intCount As Integer
Dim PrgCount As Integer
Dim intFileCount As Integer

FileSpec = IndepInsPath & "Excel Files\"

Set fs = New FileSystemObject
Set folder = fs.GetFolder(FileSpec)

intFileCount = folder.Files.Count

Set XL = New Excel.Application
PrgCount = 1
ProgBar2.Max = intFileCount

Do
For Each file In folder.Files

FName = file.Name
FilePos = InStr(1, FName, ".", vbTextCompare) - 1
FileExt = Mid(FName, FilePos + 1, FilePos)
FileRead = FileSpec & FName

NewFile = Mid(FName, 1, FilePos)

BordereauxNo = Mid(NewFile, 2, FilePos)

Set WB = XL.Workbooks.Open(FileRead)
Set WS = WB.Worksheets(1)

WS.Cells.Select
Range("A1").Select

This is where the error occurs!!!

Chet

Wamphyri
03-28-2003, 09:08 AM
Chet,

Notice that range is not referenced.
Range("A1" ).Select
use
WS.Range("A1" ).Select
instead.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum