Accessing different projects -- Help

S

singeredel

I just can't seem to figure out how to access another project's
module/procedure. I would like to access a macro procedure in
Project2.Module2 from Project1.Module1. Both projects are global templates
and appear checked under Templates and Addins, yet I get an object error.
This is what I am trying to use as code to access Project2

ReportMacros.LogFileStatistics.LogFileStatistics
(Project2, Module2, Procedure)

I have also tried a variety of other things such as
With ReportMacros.vbProject
LogFileStatistics.LogFileStatistics
End With

If I could just understand this concept, I would be so grateful.

Can someone help me understand how this works or point me somewhere where I
can read about this. I keep having the same problem with everything I attempt
outside of a particular project.
 
S

singeredel

I also have a reference to Normal (which is where Project1 is located) in the
ReportMacros project (Project2).
 
S

singeredel

I probably should specify that this attempt to access another module is done
in the code of a Userform.
 
S

singeredel

Thanks for your reply. This executed the macro but did not return me to the
rest of the procedure to finish it out.
 
T

Theo van der Ster

The fact that you execute it from a user form doesn't make any
difference. And if the macro in the other module has run and there is
more code in the user form, that should run without any problems.

So what's the whole code? I could help better if I understood exactly
what you're trying to do.

Regards,
Theo
 
S

singeredel

The userform is used to generate different medical reports. After the form is
completed and Ok button is clicked, all the variables from the userform are
established and the appropriate report template is added. The very next step
is to execute the following:

InsertBayBrookBillingSheet:

If Clinic$ = "Bay Brook" Then
ReportMacros.Report_Macros_QTC.InsertBayBrookBillingSheet
End If

The code in the macro being called is as follows:

Selection.EndKey Unit:=wdStory
ActiveDocument.Range(Start:=Selection.Start, End:=Selection.Start). _
InsertBreak Type:=wdSectionBreakNextPage
Selection.Start = Selection.Start + 1
With ActiveDocument.Range(Start:=Selection.Start, End:=ActiveDocument. _
Content.End).PageSetup
End With
Selection.Collapse Direction:=wdCollapseEnd
Selection.Style = "Default Paragraph Font"
Selection.InsertFile FileName:="C:\Garvin\Word Templates\DOL
Questions\BaybrookBillingSheet.doc"

However, using the Application.Run MacroName code just inserts the billing
sheet but then stays in the document and does not return to the code to
complete the rest of the program. I have had a problem in the past with using
this type of code. At that time it did return to the program but it skipped
the next few lines of code. So I haven't been able to figure out what is
happening.
 
T

Theo van der Ster

I have to admit I'm at a loss here too. Did you try to walk through
your code with F8? Another thing you can try is substitute the call to
the other procedure with local code, just to see where the problem
lies.

Again, I don't understand why your code shouldn't resume after the
call. Maybe someone else has a better idea.

Sorry,
Theo
 
S

singeredel

I think I figured out the problem and it had nothing to do with the form of
the code you provided. It had to do with a project that was having problems
with "disabled macros". When that problem was resolved, this seemed to work.

Thanks!
 
S

singeredel

I thought my problem was resolved, but when in step mode, using the
"Application.Run MacroName:" won't let me step back into the program after
the macro executes, so I don't know if the rest of the program is executing
correctly.
 
T

Theo van der Ster

I'm not sure but I think this is normal behavior for step mode. Find a
way around it just for testing purposes and put some local code in to
fake the results you'd otherwise get from the macro in the other
project.
 
S

singeredel

I just ended up putting the code directly in the procedure instead of trying
to call a procedure from another project module. However, it sure would be
nice to know how to do this. The procedure I am trying to call from is in the
Normal project and the procedure being called is in the
ReportMacros.Create_QTC_Report project/module. I have a reference to Normal
in the ReportMacros project because I have to access forms in Normal from
procedures in ReportMacros, but this reference to Normal in ReportMacros
precludes me from setting a reference to ReportMacros in the Normal project,
so I don't know how to be able to have a reciprocal access. I have "Get
Property" statements in the Normal project for Userforms that need to be
accessed, but I apparently cannot use a Get Property to access a module, or I
just don't know how.
 
Top