473,408 Members | 1,852 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

run stored excel VBA procedure from ACCESS

anyone know of anyway to call a subprocedure 'workbook_open()' embedded
in an excel workbook from VB in access? i'm working on some code that
was already written for an access db and has data exported to a text
file and when the excel file opens up, it loads this subprocedure
'workbook_open()' that links to this text file and processes that data.
Well, now i have to tweak this code and so i need to call this
subprocedure to run from the ADO connection i have open in ACCESS
without me having to open excel. Is there any way to do this?

Any help is much appreciated.
Angelo

Nov 13 '05 #1
1 5574
If you are referring to a subroutine written in an Excel VBA code module
here is how you invoke a sub in Excel from Access - you have to use COM
automation. First, while inside an Access code module - goto
tools/references, make a reference to the Microsoft Excel Object
Library. Now you can use this code:

Sub runExcelProcFromAccess()
Dim xlObj as Excel.Application, wkbk As Excel.WorkBook
Set xlObj = CreateObject("Excel.Application.10")
Set wkbk = xlObj.Workbooks.Open("c:\somedir\yourwkbk.xls")
wkbk.Application.Run "subSuchnSuch"
wkbk.Close
xlObj.Quit
Set xlObj = Nothing
End Sub

So you are still openeing a workbook, but only programmatically, not
physically. Also in this line

wkbk.Application.Run "subSuchnSuch"

if your sub takes arguments you can pass the arguments like this:

wkbk.Application.Run "subSuchnSuch", arg1, arg2

where arg1, arg2 could be an integer value, string value, and array.

Rich

*** Sent via Developersdex http://www.developersdex.com ***
Nov 13 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Dino L. | last post by:
How can I run stored procedure (MSSQL) ?
22
by: M K | last post by:
Heres my SP: ( i am trying to add more than 1 field but get the same error no matter how many i try to add, i thought i would try to insert the primary key only and work up from there but the...
0
by: franjorge | last post by:
Hi, I have created two stored procedures via VB using this code: sql = "CREATE PROC " & nombre_proc & " AS SELECT *" & _ " From MBM_PUNTOS_SCE_SIN_COINCIDIR_SIEGE_FALTA_PM_NE_" & mes & _ "...
1
by: KRSharp | last post by:
I am new to Access, so bear with me. I think this is possible, but I am not sure how to get this going. I am trying to develop a database that will allow me to create a manufacturing schedule...
2
by: jed | last post by:
I have created this example in sqlexpress ALTER PROCEDURE . @annualtax FLOAT AS BEGIN SELECT begin1,end1,deductedamount,pecentageextra FROM tax
3
dbushcmohle
by: dbushcmohle | last post by:
Hello, I am having problems exporting a stored procedure's results to an Excel file... I've done this many times successfully, but never had to introduce a variable. Now that I've introduced...
7
by: flickimp | last post by:
Hi I want to create a Stored Procedure in SQL with three variables that are declared in an Excel file. Thus, when the user enters the three variables into Cells A1, B1, C1 Then hits a...
1
by: flickimp | last post by:
Hi I have a stored procedure on SQL Server 2000 called: .Capacity_Planning.dbo.sp_flickimp_test I have an Excel Sheet with the 2 paramters for the Stored procedure in cells A1 and B1. How...
2
by: acw | last post by:
On a SQL Server 2000 db I would like to setup a stored procedure that accesses couple tables and runs the extended stored procedure xp..cmdshell. The goal is to grant users with limited privileges...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.