473,410 Members | 1,914 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,410 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 20 '05 #1
3 1115
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 20 '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 20 '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 20 '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: 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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
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...

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.