Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Word Form.Show from a different module

Status
Not open for further replies.

nashcom

MIS
Apr 12, 2002
91
GB
I've created a form in a global template (in the Word Startup folder). The template has the following 'modules'

Code:
GlobalPrinterControl (ie the template name)
   Forms
      PrintCopySelectForm

I want to call the form from another template using a FilePrint routine. I've tried:

Code:
Sub FilePrint()
   PrintCopySelectForm.Show
End Sub

also
Code:
Sub FilePrint()
   GlobalPrinterControl.PrintCopySelectForm.Show
End Sub

and
Code:
Sub FilePrint()
   GlobalPrinterControl.Forms.PrintCopySelectForm.Show
End Sub

I get a "Run-Time Error 424 - Object required error"

What is the correct method to display the form?

I've made sure that the GlobalPrinterControl is being loaded as a Template/Add-In. Do I need to define it as 'Global' in any way?

Thanks

David




 
I don't know if it's a long-winded way of going about it, but I managed to make it work by creating a new module in the GlobalPrinterControl template with the following code

Code:
Global Sub PrintCopySelectFormShow()
   PrintCopySelectForm.Show
End Sub

and then in the FilePrint routine in the other template I put:

Code:
Sub FilePrint()
   Application.Run MacroName:="PrintCopySelectFormShow"
End Sub

This puts the processing back to GlobalPrinterControl. Is this the 'best' way of doing it, or is what I was trying to achieve with my first posting the better?

One other question - this obviously works from the Word File/Print menu option, but is there a way to execute this code when the user clicks on the 'Print' option on the Word Toolbar?
 
1. You are correct. You can not access an object directly in another project (as in object.Show), but you CAN access a macro that does that. Which is what you did with the macro you put together.

2. Yes. The Print button is fired by the Sub FilePrintDefault. Just write a new one like:
Code:
Sub FilePrintDefault()
   Application.Run MacroName:="PrintCopySelectFormShow"
End Sub

Gerry
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top