ms word does not answer to any Add-ins at all


hi,

i newbie , realy need 3 questions have worked on them 2 weeks steel no success.

1. built shared add-in project worked on ms word dont know have changed, after many times debugging ms word not answer add-in project @ , tryed debugg code set "start external program" word.exe , used br
eak points got message
"the breakpoint not hit no symbols have been loaded document".

2. how can insert text custom property word document?

3. have built add-in excel works can not insert text activecell, can see toolbar , button can not insert text.
here litle bit of code:

excel.application excelapp = null;

public void onconnection(object application, extensibility.ext_connectmode c
onnectmode, object addininst, ref system.array custom)
{
  excelapp = (excel.application)application;
  inserttext = makeanewbutton(toolbar, "insert text", 1044, new _commandbarb
 uttonevents_clickeventhandler(inserttext
_click));
}

private commandbarbutton makeanewbutton(commandbar commandbar, string captio
n, int faceid,  _commandbarbuttonevents_clickeventhandle
r clickhandler)
  {
     object missing = system.reflection.missing.value;
     try
     {
        microsoft.office.core.commandbarbutton newbutton;
        newbutton = (commandbarbutton)commandbar.controls.add(msocontroltype
.msocontrolbutton, missing, missing, missing, missing);

         newbutton.caption = caption;
         newbutton.faceid = faceid;
         newbutton.click += clickhandler;
         return newbutton;
      }
      catch
      {
          return null;
      }
   }


public void inserttext_click(commandbarbutton barbutton, ref bool somebool)
{
   if (excelapp != null)
   {
      this.excelapp.activecell.value2 = "sometext";   
   }
}

  1. it's possible add-in disabled word. open word, click help-about. in dialog, click button 'disabled items'. if add-in in list, selected , click enable.
    if there nothing in list, open registry navigate hkey_local_machine\software\microsoft\office\word\addins. addin should listed there (most <addinname>.connect). check value of loadbehavior key. should set 3 (load on startup). it's possible registry key @ hkey_current_user instead of hkey_local_machine

  2. to add custom property, think shoud use following code (haven't tested this, don't shoot me if there's error here)

    microsoft.office.interop.word.customproperties prps = (microsoft.office.interop.word.customproperties)wordapp.activedocument.customdocumentproperties;
    prps.add("newproperty", "somevalue");

  3. does inserttext_click method gets executed when click button? have variable button declared field of connect class (if goes out of scope, gets collected gc , click stop working)?


Archived Forums V  >  Visual C# IDE



Comments

Popular posts from this blog

Azure DocumentDB Owner resource does not exist

BizTalk Server 2013 Azure VM Log Shipping and HA for hosts

How to Share webservice object to all user