Sharing VBA Code between Word and Access 2007

L

LA Lawyer

I want to share code (e.g., functions and programming notes to myself)
between my Access and Word.

How is that done?
 
J

Jeff Boyce

Not sure I'm following what you're after ...

If you have code you've written in Access, referring to Access' features and
functions, why would it work in Word, which has different features and
functions?

Regards

Jeff Boyce
Microsoft Access MVP

--
Disclaimer: This author may have received products and services mentioned
in this post. Mention and/or description of a product or service herein
does not constitute endorsement thereof.

Any code or pseudocode included in this post is offered "as is", with no
guarantee as to suitability.

You can thank the FTC of the USA for making this disclaimer
possible/necessary.
 
L

LA Lawyer

Actually, I am using Word and Access to do some very similar date math and
other functions.

Also, I have been documenting my snippets of code and other reminders and
I'd not to post that this.
 
J

Jeff Boyce

I guess I'm still not clear on what you want to end up with.

If you are already copying snippets and pasting into a Word document, what
more are you after?

Regards

Jeff Boyce
Microsoft Access MVP

--
Disclaimer: This author may have received products and services mentioned
in this post. Mention and/or description of a product or service herein
does not constitute endorsement thereof.

Any code or pseudocode included in this post is offered "as is", with no
guarantee as to suitability.

You can thank the FTC of the USA for making this disclaimer
possible/necessary.
 
L

LA Lawyer

I am interested in two things:

1. Making VBA-related notes to myself that is applicable both to Access and
Word. I am tried of putting identical notes in twice.

2. I have set up a system where Word is accessing Access data for lots of
things. Thus, I can share some functions, particularly when Word uses data
from directly from Access.
 
T

Tom van Stiphout

Unfortunately there is no way to create one "object" in Access or Word
and share it in both environments. There is a way to create an
"object" and share it between two Access projects (this is called an
add-in or .mda), but not between Access and Word.
The closest thing you can do is create one "code library" as a text
file, and import it in both environments. In the VBA editor right
click a code module and use the Import File and Export File options.
As Jeff hinted at, you can only use features that are common to both,
or your code will not compile.
You could create a COM DLL in Visual Basic 6, or a .NET DLL using VSTO
and Visual Studio. Both could be used from Access and Word.

-Tom.
Microsoft Access MVP
 
J

Jeff Boyce

Thanks for jumping in, Tom. I knew I wasn't following ...<g>!

Regards

Jeff Boyce
Microsoft Access MVP

--
Disclaimer: This author may have received products and services mentioned
in this post. Mention and/or description of a product or service herein
does not constitute endorsement thereof.

Any code or pseudocode included in this post is offered "as is", with no
guarantee as to suitability.

You can thank the FTC of the USA for making this disclaimer
possible/necessary.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top