Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / February 2005

Tip: Looking for answers? Try searching our database.

VBA Code to Access Another Project

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
singeredel - 12 Feb 2005 03:55 GMT
How do I write code to access and run a procedure in a module in another
project. When the project template is opened in the Visual Basic Editor, it
appears as follows:

Julie(JuliePersonal), with Julie being the project name and (JuliePersonal)
being the open template. I need to write code to run a procedure in the Julie
project from the Normal template.

I have tried many things, including the following:

   With Julie.VBProject
       CreateReport.CreateReport
   End With

(CreateReport being the module and .CreateReport being the procedure)

However, I get a run-time error 424: Object required.

Signature

singeredel

Jezebel - 13 Feb 2005 01:18 GMT
Open and activate the JuliePersonal project. In VBE, go to Tools >
References. Check the box alongside Julie.

Then in your code you can use: Julie.[ModuleName].CreateReport

[ModuleName] is the name of the code module containing the CreateReport
function.

> How do I write code to access and run a procedure in a module in another
> project. When the project template is opened in the Visual Basic Editor,
[quoted text clipped - 16 lines]
>
> However, I get a run-time error 424: Object required.
singeredel - 14 Feb 2005 17:29 GMT
I am trying to access the Julie project from the Normal template project. I
previously tried creating a reference to Julie in the Normal project, but I
get an error that "Cyclic reference of projects is not allowed." I have a
reference to Normal in the Julie project to access a module in the Normal
project from the Julie project. Now I need the reverse to happen -- to be
able to access a module in Normal from Julie.

> Open and activate the JuliePersonal project. In VBE, go to Tools >
> References. Check the box alongside Julie.
[quoted text clipped - 24 lines]
> >
> > However, I get a run-time error 424: Object required.
singeredel - 14 Feb 2005 17:31 GMT
Sorry, my last sentence was wrong -- I need to now access the Julie project
from the Normal project.

Thx...

> Open and activate the JuliePersonal project. In VBE, go to Tools >
> References. Check the box alongside Julie.
[quoted text clipped - 24 lines]
> >
> > However, I get a run-time error 424: Object required.
Tom Winter - 15 Feb 2005 14:10 GMT
This might not apply directly, but I thought these examples I wrote up for
another post might help you out:

To access "macros" in an add-in (global) template, you do not need to add a
reference
to it for the current document/project. The following are equivalent:

### Example 1 ###

' MyProject.ThisDocument has had a reference added to the template
Macros.dot. In this case, Macros.dot does not need to be loaded as an add-in
(global) template.

Sub Test

   MacrosProjectName.ModuleName.PublicRoutineName x, y, z    ' You don't
really need to include .ModuleName, but you can if you want.

End Sub

### Example 2 ###

' Macros.dot is loaded as an add-in (global) template, either by the user
from TOOLS | TEMPLATES AND ADD-INS, by code, or by being in the STARTUP
folder.

Sub Test

   Application.Run "PublicRoutineName", x, y, z    ' Application.Run in
Word 2000 or later will return the return value from the routine.

End Sub

### Example 3 ###

' The document has it's attached template set to Macros.dot

Sub Test

    MacrosProjectName.ModuleName.PublicRoutineName x, y, z    ' You don't
really need to include .ModuleName, but you can if you want.

End Sub

####

Signature

Tom Winter
tom@nospam.amosfivesix.com

> How do I write code to access and run a procedure in a module in another
> project. When the project template is opened in the Visual Basic Editor,
[quoted text clipped - 16 lines]
>
> However, I get a run-time error 424: Object required.
singeredel - 15 Feb 2005 18:31 GMT
Thank you so much for your reply. I am either not understanding what you have
written or something else is going on. I have tried the following code:

   AddIns("C:\Julie-Personal\Word Templates\Master
Template\JuliePersonal.dot").Installed = True
   
   Application.Run MacroName:="Julie.Create_Julie_Report.Create_Julie_Report"

(I have also tried: Julie.Create_Julie_Report.Create_Julie_Report and just
plain Julie.Create_Julie_Report)

I have installed the template "JuliePersonal.dot" as per above. I am trying
to run the procedure listed above from the Normal project but I am getting a
run-time error   '-2147352573(8002003)" indicating "unable to run specified
macro" or "Object required."  

I have a reference to "Normal" in my "Julie" project because I also need to
access a module in the Nomal template when using the "Julie" project and it
would not run that procedure until I added a reference to Normal.

If the "Julie" template is installed, why wouldn't everything in that
template be available from any project? Is there some place where you have to
indicate that the module is "Public?"

Thanks!

> This might not apply directly, but I thought these examples I wrote up for
> another post might help you out:
[quoted text clipped - 62 lines]
> >
> > However, I get a run-time error 424: Object required.

Rate this thread:






 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.