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 / October 2006

Tip: Looking for answers? Try searching our database.

How do I Call an Addin's methods from a template?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
JeffP@Work - 12 Oct 2006 17:05 GMT
If I have one addin and I want to have add specific ADO SQL query to just
ONE template dot, when this one dot is launched (via automated process, no
user intervention and off to the printer it goes) I want to know if and how
to access the methods in the addin from the dot?

How do I access the methods in the addin?

How do I make sure that the dot fires AFTER the addin's auto_exec?

I have an automated printing process that is launched from an app & DDE
server that will give me a recID to do my query.

There is one generic addin to support this process, I want to add code in
just one template to retrieve data not exposed by the application.

In a perfect world, the primary addin's auto_exec will fire establishing the
functions needed by the dot's ADO query.

TIA

JeffP...
Shauna Kelly - 13 Oct 2006 12:56 GMT
Hi Jeff

>> How do I access the methods in the addin?
There are three steps:

1. Open the add-in using File > New. In the VBE, in the project explorer,
right-click the name of the project (eg 'Template Project') and give it a
name. Save and close.

2. In your template, in the VBE, Tools > References. Set a reference to your
add-in.

3. In your template's code, use MyAddIn.MySubName

>> How do I make sure that the dot fires AFTER the addin's auto_exec?

I understand that prayer helps. Sprinkling DoEvents liberally in all code
helps a bit more. See the thread here for typical issues:
http://groups.google.com.au/group/microsoft.public.word.vba.general/browse_frm/t
hread/76c5724597d08ea2/3ece763790c6f330


Hope this helps.

Shauna Kelly.  Microsoft MVP.
http://www.shaunakelly.com/word

> If I have one addin and I want to have add specific ADO SQL query to just
> ONE template dot, when this one dot is launched (via automated process, no
[quoted text clipped - 17 lines]
>
> JeffP...
JeffP@Work - 13 Oct 2006 18:50 GMT
Shauna,

Re-reading the last cell re Addin
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/modcore/html/de
ovrworddocumenttemplatesvswordaddinsglobaltemplates.asp


I found setting a "Ref" and now I have the methods available to me.

I've added to my template....

In "ThisDoc..."

Option Expl....
----------------------------
Public Sub AutoOpen()
   MyLocalModule.MySub
End Sub
----------------------------

Which MySub is a wrapper for anything that will happen in this template.

I also found DocProperty so I can assign my returned values from my SQL
query to merge fields w/in the doc.

It's not fully tested but it appears to be working.

My templates are printed by a "Print" cmd, w/no user interaction similar to
using a right-click |Print and pray that my fields are updated, SalesPeople
hate when their commision coding is done wrong.

TIA

JeffP....

> Hi Jeff
>
[quoted text clipped - 42 lines]
>>
>> JeffP...
 
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.