slaprade

I am using Word 2007, VSTO2005SE and Visual Studio VB to create a shared addin automation app.

I have an "other" app that launches Word calling a particular Sub in my dotm file

The dotm declares the addin like this "Public MCTai As New MCTClass07.Class07"

The dotm calls Class07 routines that load Class07 tables from SQL. This call resides in the routine called by the "other" app

Subs executed from the dotm that display table.row.count show that these tables have data

I have created Tabs in the Ribbon with some success using callbacks for buttons to the .net code

The problem starts when I try to populate a dropDown with data from these local tables

I can populate the dropDown with static data in the GetItemCount, GetItemLabel and GetItemID functions

When I replace the static data with table information like GetItemLabel = DV_APC.Item(X).Item(1).ToString, I get error messages NOT when Word starts but when I try to select the dropDown. The error messages indicate there is no data in DV_APC

When I put a MSGBOX for the table.row.count of a table in the GetItemLable function, it displays 0 rows

The core of the dotm looks like this

Public WithEvents appWord As Word.Application
Public MCTai As New MCTClass07.Class07

Public Function MSGatewayInitialize(OdbcStr As String, LibName As String, recordID As Long, docName As String, ByRef rcMsg As String) As Long
Dim returnCode As Long

returnCode = 0
Call Register_Event_Handler(OdbcStr) 'add event handler

On Error GoTo init_error

Call MCTai.InitDocument(ActiveDocument, OdbcStr, LibName, recordID)
Call Module1.KeepData(OdbcStr, LibName) 'this call will save data to MCTai and load tables from SQL

On Error GoTo 0
MSGatewayInitialize = returnCode
Exit Function

init_error:
MsgBox (Err.Description) + vbCrLf + "Initialization error"
Err.Clear
returnCode = -1

End Function

So my question may be "What is the order of these parts loading"

Or my question may be "how do I read SQL tables into the dropDowns of the ribbon since I have to make the queries to SQL from my code"



Re: Visual Studio Tools for Office ribbon dropDown in Word

Rachel Schaw - MSFT

Hi there,

The GetItemCount calldown/function is called to load he dropdown items when the user clicks on the dropdown. If MSGatewayInitilaize is being called prior to that then you wouldn't have any data in your table toload.

There are a couple ways you could accomplish what you're trying to do.

1) Call MSGatewayInitialize in your Ribbon OnLoad callback

2) Call MSGatewayInitialize in your GetItemCount function

I may not understand your scenario exactly. If that's the case, if you can provide more information about when your MSGatewayInitialize is being called I might be able to provide a better solutions.

Rachel





Re: Visual Studio Tools for Office ribbon dropDown in Word

slaprade

Thanks for the response

The MSGatewayInitialize is actually being called from my vendor's application so it is the very first thing being executed. I have discovered some additional information

I have a DV_APC declared in the .net as a public Dataview

I fill that DV while in the MSGATewayInitialize routine

I have two subs in Word.Thisdocument

One of these calls runs a sun in the .net app that does a msgbox(dv_apc.count)

The other does a msgbox(MCTai.dv_apc.count) --- MCTai being the declared value for Class07 (my .net code)

The first macro reports 14 items in DV_APC

the second macros reporst an error "Object Required"

I believe that Word may know about MCTai because it executes routines from there but not the variables declared as public in it.

What is "Global" as part of a call - I see it used in some example (maybe Office 2003) but I cannot find a definition of how to use it or what it might do for me