How to reference Userform in another project

S

singeredel

I am trying to figure out how to reference a form in another project in order
to pass variables to it. This is what I have:

With Hannani_TestTemplate.frmCreate_Hannani_Personal
.txtRptDateMonth.Text = "02"
.txtRptDateDay.Text = "17"
.txtRptDateYear.Text = "2005"
.show
End With

The project name is "Hannani." The template name is "Hannani_Test.dot", the
form name is "frmCreate_Hannani_Personal". I keep getting an "object" error.

Thank you.
 
J

Jezebel

You can do it by adding a reference: Make sure the Hannani_Test template is
loaded -- either directly or because you have a document based on it. Select
the source project in VBA, then go to Tools > References. Scroll down until
you find Hannani_Test and check the box next to it.

Bear in mind that Hannani_Test has to be loaded every time for your code to
work. A better approach might be to put the common code into an add-in, to
be called by any project -- including Hannani -- that needs it.
 
U

Ulf Nilsson

Hi,
Is it possible to select this template using VBA? We have
templates in the user's profile that needs to connect to
each other.

/ Ulf
 
S

singeredel

"I can't seem to get this to work. I have a reference to "Hannani_Test.dot"
in the "InitialVariables" project, "Initial_Variables" module, "References".
Both "Hannani_Test.dot and "InitialVariables.dot" are checked in "Templates
and Add-Ins." The following Procedure appears in the InitialVariables
Project, Initial_Variables module:

Sub Test()

With Hannani_TestTemplate.frmCreate_Hannani_Report
.txtReportDateMonth.Text = "02"
.txtReportDateDay.Text = "17"
.txtReportDateYear.Text = "2005"
.txtDictationDateMonth.Text = "02"
.txtDictationDateDay.Text = "17"
.txtDictationDateYear.Text = "2005"
.txtBillingPeriod.Text = "021605-022805"
.optLosAngeles.Value = False
.optSanBernardino.Value = False
.optWestCovina.Value = True
.Show
End With

End Sub

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

What am I missing?
 

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