473,320 Members | 1,863 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,320 software developers and data experts.

Accessing a VBA module from VB or C#. Maybe a better solution?

Hi,

This does sound like a bit of a weird thing to ask so I will state my
question and then further down explain why I am trying to do it. So
if you have the answer then reply! Or if you understand what I am
trying to do and can suggest a better solution then reply also!

Question
--------
I want to run a VBA code module from either VB/VB.NET/C#. How can I
go about calling the call module?

Why
---

I have an MS Access project that is hooked up with SQL-MSDE. I have
developed a complex and nice looking report. What I want to do is let
my work colleges view it over the internal intranet. The Data Access
Pages doesn't seem to work - Access throws a fit over the calulated
fields. In Access though you can use the ExportXML feature and it
creates the XML files that can be viewed in any web browser. So I
have written a code module that does this in the Access project. I
then want to run this and the XMl files will get updated. Simple
request I thought..

Any help, as always, greatly appreciated.

cheers
Mike
Nov 15 '05 #1
3 1257
You can use automation to achieve this:

Dim acc As Object

Set acc = CreateObject("Access.Application")

acc.OpenCurrentDatabase "PathToYourDB"
acc.DoCmd.OpenModule "ModuleName", "ProcedureName"

Set acc = Nothing

"Mike" <mi*********@tiscali.co.uk> wrote in message
news:73*************************@posting.google.co m...
Hi,

This does sound like a bit of a weird thing to ask so I will state my
question and then further down explain why I am trying to do it. So
if you have the answer then reply! Or if you understand what I am
trying to do and can suggest a better solution then reply also!

Question
--------
I want to run a VBA code module from either VB/VB.NET/C#. How can I
go about calling the call module?

Why
---

I have an MS Access project that is hooked up with SQL-MSDE. I have
developed a complex and nice looking report. What I want to do is let
my work colleges view it over the internal intranet. The Data Access
Pages doesn't seem to work - Access throws a fit over the calulated
fields. In Access though you can use the ExportXML feature and it
creates the XML files that can be viewed in any web browser. So I
have written a code module that does this in the Access project. I
then want to run this and the XMl files will get updated. Simple
request I thought..

Any help, as always, greatly appreciated.

cheers
Mike

Nov 15 '05 #2
Scott's concept is a good one, and it should make it clear that Access must
be installed on the machine where this code is running.
The code he supplies is in VB6.0; the same thing can be done in .NET
languages, but the syntax is a little different.

The one problem I see is in this line:
acc.DoCmd.OpenModule "ModuleName", "ProcedureName"

This will open the module for editing, which is not, I believe, what is
desired.
Make sure the procedure you want to call (I'll call it MyProcedure) is
declared as Public.
Then you can call it like this:
acc.MyProcedure

However, this is still a kludgy way to display a report on an Internet page.
You might want to look into Front Page - or since you mention .NET, try
ASP.NET - it's incredibly powerful!

HTH
- Turtle
"Scott McDaniel" <sc***@no.spam.thedatabaseplace.net> wrote in message
news:_J********************@comcast.com...
You can use automation to achieve this:

Dim acc As Object

Set acc = CreateObject("Access.Application")

acc.OpenCurrentDatabase "PathToYourDB"
acc.DoCmd.OpenModule "ModuleName", "ProcedureName"

Set acc = Nothing

"Mike" <mi*********@tiscali.co.uk> wrote in message
news:73*************************@posting.google.co m...
Hi,

This does sound like a bit of a weird thing to ask so I will state my
question and then further down explain why I am trying to do it. So
if you have the answer then reply! Or if you understand what I am
trying to do and can suggest a better solution then reply also!

Question
--------
I want to run a VBA code module from either VB/VB.NET/C#. How can I
go about calling the call module?

Why
---

I have an MS Access project that is hooked up with SQL-MSDE. I have
developed a complex and nice looking report. What I want to do is let
my work colleges view it over the internal intranet. The Data Access
Pages doesn't seem to work - Access throws a fit over the calulated
fields. In Access though you can use the ExportXML feature and it
creates the XML files that can be viewed in any web browser. So I
have written a code module that does this in the Access project. I
then want to run this and the XMl files will get updated. Simple
request I thought..

Any help, as always, greatly appreciated.

cheers
Mike


Nov 15 '05 #3
Thanks for that - I will try it tonight.

"Scott McDaniel" <sc***@no.spam.thedatabaseplace.net> wrote in message news:<_J********************@comcast.com>...
You can use automation to achieve this:

Dim acc As Object

Set acc = CreateObject("Access.Application")

acc.OpenCurrentDatabase "PathToYourDB"
acc.DoCmd.OpenModule "ModuleName", "ProcedureName"

Set acc = Nothing

"Mike" <mi*********@tiscali.co.uk> wrote in message
news:73*************************@posting.google.co m...
Hi,

This does sound like a bit of a weird thing to ask so I will state my
question and then further down explain why I am trying to do it. So
if you have the answer then reply! Or if you understand what I am
trying to do and can suggest a better solution then reply also!

Question
--------
I want to run a VBA code module from either VB/VB.NET/C#. How can I
go about calling the call module?

Why
---

I have an MS Access project that is hooked up with SQL-MSDE. I have
developed a complex and nice looking report. What I want to do is let
my work colleges view it over the internal intranet. The Data Access
Pages doesn't seem to work - Access throws a fit over the calulated
fields. In Access though you can use the ExportXML feature and it
creates the XML files that can be viewed in any web browser. So I
have written a code module that does this in the Access project. I
then want to run this and the XMl files will get updated. Simple
request I thought..

Any help, as always, greatly appreciated.

cheers
Mike

Nov 15 '05 #4

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

Similar topics

6
by: Dan Ellis | last post by:
Hi, I've been down so many dead ends trying to get something working, so I'm really hoping someone can help out. I need to access an Oracle database running on a Windows server from Python...
2
by: | last post by:
Hi, This does sound like a bit of a weird thing to ask so I will state my question and then further down explain why I am trying to do it. So if you have the answer then reply! Or if you...
6
by: Mike | last post by:
Hi, This does sound like a bit of a weird thing to ask so I will state my question and then further down explain why I am trying to do it. So if you have the answer then reply! Or if you...
9
by: Bob | last post by:
Hello: I have a form with 26 panels. Each panel has a bunch of other controls in it. The panels visible property are set to False. Each panel has a corosponding button to set it's visible...
6
by: garyjefferson123 | last post by:
I'm having a scoping problem. I have a module called SpecialFile, which defines: def open(fname, mode): return SpecialFile(fname, mode) class SpecialFile: def __init__(self, fname, mode):...
14
by: James Thiele | last post by:
I'd like to access the name of a function from inside the function. My first idea didn't work. >>> def foo(): .... print func_name .... >>> foo() Traceback (most recent call last): File...
10
by: Bonzol | last post by:
vb.net Hey there, could someone just tell me what the differnce is between classes and modules and when each one would be used compared to the other? Any help would be great Thanx in...
2
by: applegreenss | last post by:
Is it possible to take the contents of a MySQL DB Table, and somehow put the data into a syntax-correct data file format like a delimited ..txt file, and using PHP parse it as a local c:\ file...
13
by: Kirk | last post by:
I have been reading Scott Allen's article on Master Pages (http:// odetocode.com/Articles/450.aspx) but I am having problems understanding a concept. Specifically, I have created a property...
13
by: Rafe | last post by:
Hi, I am in a situation where I feel I am being forced to abandon a clean module structure in favor of a large single module. If anyone can save my sanity here I would be forever grateful. My...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....

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.