473,487 Members | 2,622 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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 12 '05 #1
6 8590
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 12 '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 12 '05 #3
rkc

"MacDermott" <ma********@nospam.com> wrote in message
news:1%******************@newsread1.news.atl.earth link.net...
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.


Visual Studio doesn't seem to be able to create the necessary assemblies
for the Access Object Libraries. It chokes when trying to convert some
of the support libraries.

Works O.K. with Outlook, Word, Excel, Dao 3.6... just not Access. At least
not 8 or 10. Have you done this?
Nov 12 '05 #4
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 12 '05 #5
I've done it with VB 6.0, but since you use the term "assemblies" I'm
guessing that you're using .NET.
Would that be correct?

- Turtle

"rkc" <rk*@yabba.dabba.do.rochester.rr.bomb> wrote in message
news:Xr********************@twister.nyroc.rr.com.. .

"MacDermott" <ma********@nospam.com> wrote in message
news:1%******************@newsread1.news.atl.earth link.net...
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.


Visual Studio doesn't seem to be able to create the necessary assemblies
for the Access Object Libraries. It chokes when trying to convert some
of the support libraries.

Works O.K. with Outlook, Word, Excel, Dao 3.6... just not Access. At least
not 8 or 10. Have you done this?

Nov 12 '05 #6
rkc

"MacDermott" <ma********@nospam.com> wrote in message
news:AC******************@newsread2.news.atl.earth link.net...
I've done it with VB 6.0, but since you use the term "assemblies" I'm
guessing that you're using .NET.
Would that be correct?


I was asking about .Net, yes.

I was wondering if I was having problems, or if .Net just isn't up to
speed with Access yet.


Nov 12 '05 #7

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

Similar topics

8
6964
by: gsv2com | last post by:
One of my weaknesses has always been pattern matching. Something I definitely need to study up on and maybe you guys can give me a pointer here. I'm looking to remove all of this code and just...
2
1617
by: Martin Drautzburg | last post by:
Withing a module I can assign a value to a global var by assigning to it in the outermost scope. Fine. But how can I do this if the attribute name itself is kept in a variable. Once the module...
3
1158
by: Dayne | last post by:
Hi Everyone! Currently, I am writing an application that uses a lot of bitmaps. I would load a image by specifying "a path" on my hard drive. I would however like a better solution --- don't...
3
1259
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...
19
1846
by: Ornette | last post by:
Hello, I'm trying to convert strings to upper without the accents. For the moment, ToUpper converts é to E with an accent... I tried to set up english culture (en) but it's the same... Any...
2
1477
by: kaferro | last post by:
I use the following code to reset an ID when an order has been filled by more than one trade. For example, order= buy 9 corn, order ID = 101. If the order is filled with three separate trades of,...
3
2250
by: cjt22 | last post by:
Hi I am new to Python (I have come from a large background of Java) and wondered if someone could explain to me how I can access variables stored in my main module to other functions within...
13
2823
by: S James S Stapleton | last post by:
I have some code, and I want to make it future-resistant. I have a bunch of variables that are set up run-time, and once set up, should act as constants. I don't want to #define them, because their...
0
7106
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
6967
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
7137
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
7181
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
4874
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
4565
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...
0
3076
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3071
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1381
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.