Group:  Microsoft Access ยป microsoft.public.access.externaldata
Thread: Viewing Excel From Access

DotNetBag
.NET Development Newsgroups

HTVi
TV Discussion Newsgroups

Our Hot Pick: Rising Antivirus 2006 - Certified by TUV & Checkmark! Get 10% discount by entering this coupon code: ONDISCOUNT10
Rising Antivirus 2006

Viewing Excel From Access
"Ronster" <rconners[ at ]keenan.com> 11.07.2006 21:40:35
Using the following code I'm trying to open an Excel file called
TestFile.XLS, switch to a sheet called Status and then move to D1. The
file opens ok but does not switch to Status or go to D1. Instead it
just hangs until I click on the Access application or unload Excel,
then I get the message saying "Testing" but it still does not switch
sheets or location. I've tried several variations of this same program
but can't get Excel to switch sheets or location from Access. Any help
is appreciated.

Sub GetExcel_2()

Dim xlx As Object, xlw As Object, xls As Object, xlc As Object

On Error Resume Next
Set xlx = GetObject(, "Excel.Application")
If Err.Number <> 0 Then
Set xlx = CreateObject("Excel.Application")
End If

On Error GoTo 0

' Comment out the next line if you don't want EXCEL to be "seen" by
user
xlx.Visible = True

Set xlw = xlx.workbooks.Open("C:\Temp\Temp\TestFile.xls")
Set xls = xlw.Worksheets("Status")
Set xlc = xls.Range("D1")

MsgBox "Testing"
'
' do other things here
'
Set xlc = Nothing
Set xls = Nothing
'xlw.Save
xlw.Close False
Set xlw = Nothing
xlx.Quit
Set xlx = Nothing

End Sub

Home | Search | Terms | Imprint | Contact
Newsgroups Reader - provided by WiredBox.Net