Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 57
Default Help Please: Run Excel based sub from Access using GetObject

I'm running Excel from Access 2k. (I must use late binding because early
binding results in Excel left Task Mgr. Processes after routine completes.)

Running looping code residing in Excel via Access is much faster than
running that code from Access. Thus, I must use late binding and I must run
code in Excel from Access.

Problem: With early binding (Application.Run "MyExcelBasedSubroutine") I get
no errors running the code. With late binding I do. But I must use late
binding as stated. I'm getting errors on both line ** and line ****. Please
help.

Code:

Set objExcel = GetObject(vFullPath)
Set objXLApp = objExcel.Parent

On Error GoTo 0
If objExcel Is Nothing Then
Set objExcel = CreateObject("Excel.Application")
IStartedXL = True
End If

objXLApp.Visible = True
objExcel.Parent.windows(2).Visible = True


'faster to run Excel routine from within Excel:
If answr = "Res" Then
objXLApp.Run "cycleRes" 'sub is in Excel module "modCycle" '**
Else answr = "Nres" Then
objXLApp.Module("modCycle").Run "cycleNRes" '****
End If
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default Help Please: Run Excel based sub from Access using GetObject

And the error message is?

"Perico" wrote:

I'm running Excel from Access 2k. (I must use late binding because early
binding results in Excel left Task Mgr. Processes after routine completes.)

Running looping code residing in Excel via Access is much faster than
running that code from Access. Thus, I must use late binding and I must run
code in Excel from Access.

Problem: With early binding (Application.Run "MyExcelBasedSubroutine") I get
no errors running the code. With late binding I do. But I must use late
binding as stated. I'm getting errors on both line ** and line ****. Please
help.

Code:

Set objExcel = GetObject(vFullPath)
Set objXLApp = objExcel.Parent

On Error GoTo 0
If objExcel Is Nothing Then
Set objExcel = CreateObject("Excel.Application")
IStartedXL = True
End If

objXLApp.Visible = True
objExcel.Parent.windows(2).Visible = True


'faster to run Excel routine from within Excel:
If answr = "Res" Then
objXLApp.Run "cycleRes" 'sub is in Excel module "modCycle" '**
Else answr = "Nres" Then
objXLApp.Module("modCycle").Run "cycleNRes" '****
End If

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 57
Default Help Please: Run Excel based sub from Access using GetObject

"Object does not support this property error 438."

Here is some simpler Access code I tested tonight and it too did not work.
As per articles expunging Excel from memory, I used late binding and set
no reference to the Excel Object library:

Sub Test()
Dim xlApp As Object
Dim oWb As Object
Dim oWs As Object
Set xlApp = GetObject("C:\Test\TestAutoma.xls")
Set oWb = xlApp.Workbook
Set oWs = xlApp.oWb("Sheet1")
xlApp.Visible = True
oWs.Visible = True
oWs.Application.Run "TestAutomation" 'modcycle module
End Sub


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 57
Default Help Please: Run Excel based sub from Access using GetObject

Disregard. This code from Access 97 Developer's Handbook, pg 432 worked,
with slight modification, Dimming as Object:

Sub Test()
On Error Resume Next
'Dim xlApp As Object
'Dim ref As Reference
'Set ref = References!Excel

Dim XL As Object
Set XL = GetObject("C:\Test\TestAutoma.xls", "Excel.Sheet")

XL.Application.Visible = True
XL.Application.Windows("TestAutoma.xls").Visible = True

XL.Application.Run "TestAutomation" 'modcycle module

XL.Close
Set XL = Nothing
End Sub
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
GetObject method from excel to other application from remote server sandra mangunsong via OfficeKB.com Excel Programming 1 February 24th 05 07:13 PM
Controlling Reflection1 from Excel using getObject Michael Nisgore Excel Programming 0 March 3rd 04 03:30 AM
Invoking Excel via Getobject(From Access) to invoke Excel Macro Acie[_2_] Excel Programming 1 February 27th 04 07:56 PM
Is there a better option than Getobject to access a .xls? Dave F[_4_] Excel Programming 4 October 28th 03 02:24 PM
Excel Getobject error Jaya Excel Programming 4 July 17th 03 07:13 PM


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