473,804 Members | 3,228 Online
Bytes | Software Development & Data Engineering Community
+ 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 8610
You can use automation to achieve this:

Dim acc As Object

Set acc = CreateObject("A ccess.Applicati on")

acc.OpenCurrent Database "PathToYour DB"
acc.DoCmd.OpenM odule "ModuleName ", "ProcedureN ame"

Set acc = Nothing

"Mike" <mi*********@ti scali.co.uk> wrote in message
news:73******** *************** **@posting.goog le.com...
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.OpenM odule "ModuleName ", "ProcedureN ame"

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. thedatabaseplac e.net> wrote in message
news:_J******** ************@co mcast.com...
You can use automation to achieve this:

Dim acc As Object

Set acc = CreateObject("A ccess.Applicati on")

acc.OpenCurrent Database "PathToYour DB"
acc.DoCmd.OpenM odule "ModuleName ", "ProcedureN ame"

Set acc = Nothing

"Mike" <mi*********@ti scali.co.uk> wrote in message
news:73******** *************** **@posting.goog le.com...
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********@nos pam.com> wrote in message
news:1%******** **********@news read1.news.atl. earthlink.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. thedatabaseplac e.net> wrote in message news:<_J******* *************@c omcast.com>...
You can use automation to achieve this:

Dim acc As Object

Set acc = CreateObject("A ccess.Applicati on")

acc.OpenCurrent Database "PathToYour DB"
acc.DoCmd.OpenM odule "ModuleName ", "ProcedureN ame"

Set acc = Nothing

"Mike" <mi*********@ti scali.co.uk> wrote in message
news:73******** *************** **@posting.goog le.com...
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.dabb a.do.rochester. rr.bomb> wrote in message
news:Xr******** ************@tw ister.nyroc.rr. com...

"MacDermott " <ma********@nos pam.com> wrote in message
news:1%******** **********@news read1.news.atl. earthlink.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********@nos pam.com> wrote in message
news:AC******** **********@news read2.news.atl. earthlink.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
6984
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 use pattern matching to determine if the proper amount of numeric characters has been met. Here is the function I've already done. Any help you can give in a pattern matching solution would be much appreciated and very educational.
2
1632
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 is loaded I can access the module's namespace no problem, but inside the module the dictionary is not yet present right ? IOW how can I write something like
3
1174
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 like the fact that the images are exposed so publicly. Any ideas? Dayne
3
1273
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 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
19
1881
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 ideas ? Ornette.
2
1498
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, say, 3 each, I need three order IDs (i.e. 101.1, 101.2, 101.3). My simple solution was to use a "char" set to '0' then increment the char for each multiple ID. This works fine if there are only 10 "multi ID trades", but after that the ascii...
3
2280
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 other modules called from this module for example file: main.py
13
2848
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 values are determined during the execution of the initialization routines, so I made them const (I'd rather making it hard for a dev to accidentally overwrite the values). The problem is, they are being set run-time by the return of a function...
0
9708
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9588
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10340
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10327
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7625
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6857
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5527
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5663
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2999
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.