|
|
|
date: Mon, 24 Oct 2005 19:02:21 +0200,
group: microsoft.public.word.vba.addins
back
Re: Exception when adding a toolbar as a word-addin
Sorry!!! I clicked reply on a formerly stored message to find a
apropriate group, but forgot to check the other groups in the header.
My mistake, sorry again...
On Mon, 24 Oct 2005 10:09:10 -0700, "Bob Butler"
wrote:
>"Matthias Langbein" wrote in message
>news:qc4ql1lfjp06ia2rhjiga752kqd4m091jl@4ax.com
>> Hi all,
>>
>> I tried to build a MSDN-Tip how to integrates a word-toolbar in a
>> addin:
>>
>(http://support.microsoft.com/Default.aspx?kbid=302901#XSLTH3228121124120121
>120120)
>>
>> The class member applicationObject was initialized with the
>> word-application-objekt. When calling
>>
>>
>> Microsoft.Office.Core.Commandbar toolbar = null;
>> try
>> {
>> toolbar = (Microsoft.Office.Core.CommandBar)_
>> applicationObject.CommandBars.Add("My Toolbar",_
>> Microsoft.Office.Core.MsoBarPosition.msoBarFloating,_
>> System.Reflection.Missing.Value, true);
>> }
>> catch (Exception ee)
>> {
>> .....
>> }
>>
>>
>> I recieve the exception:
>> "Der Objektverweis wurde nicht auf eine Objektinstanz festgelegt."
>> which means pretty much:
>> "The bject link was not assigned with a object instance."
>>
>> How comes? I'm desparate...
>> THX for all the help, yours Langi
>
>You are writing an add-in using C# and posted the question to a COM group
>and 2 VB groups?
>
>Try searching for newsgroups containing .dotnet. in the name.
date: Mon, 24 Oct 2005 20:11:21 +0200
author: Matthias Langbein
Re: Exception when adding a toolbar as a word-addin
Hi all,
I decided to post the code, maybe someone can tell me why there is the
exception...
namespace MyOwnAddIn
{
using System;
using Microsoft.Office.Core;
using Extensibility;
using System.Runtime.InteropServices;
using Word = Microsoft.Office.Interop.Word;
[GuidAttribute("715D48EE-9F94-4055-AC62-4D22E89913AD"),
ProgId("MyOwnAddIn.Connect")]
public class Connect : Object, Extensibility.IDTExtensibility2
{
public Connect()
{
}
public void OnConnection(object application,
Extensibility.ext_ConnectMode connectMode, object addInInst,
ref System.Array custom)
{
applicationObject = application;
addInInstance = addInInst;
if (application is Word.Application)
{ wordApp = (Word.Application)application; }
Microsoft.Office.Core.CommandBar toolBar = null;
if (wordApp != null)
{ toolBar = AddWordToolbar(wordApp, "Some useful toolbar."); }
}
public void OnDisconnection(Extensibility.ext_DisconnectMode
disconnectMode, ref System.Array custom)
{
}
public void OnAddInsUpdate(ref System.Array custom)
{
}
public void OnStartupComplete(ref System.Array custom)
{
}
public void OnBeginShutdown(ref System.Array custom)
{
}
private Microsoft.Office.Core.CommandBar
AddWordToolbar(Word.Application word, string toolbarName)
{
Microsoft.Office.Core.CommandBar toolBar = null;
try
{
object missing = System.Reflection.Missing.Value;
toolBar = (Microsoft.Office.Core.CommandBar)
wordApp.CommandBars.Add(toolbarName,
Microsoft.Office.Core.MsoBarPosition.msoBarTop,
missing, true );
toolBar.Visible = true;
return toolBar;
}
catch (Exception ee)
{
System.Windows.Forms.MessageBox.Show(ee.Message);
return null;
}
}
private object applicationObject;
private object addInInstance;
private Word.Application wordApp = null;
}
}
date: Tue, 25 Oct 2005 22:12:15 +0200
author: Matthias Langbein
Re: Exception when adding a toolbar as a word-addin
I get the warning:
'Microsoft.Office.Core.CommandBar' is defined in multiple places;
using definition from
'c:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\office.dll'
Might this have anything to do with it? And how do I solve this
problem?
On Tue, 25 Oct 2005 22:12:15 +0200, Matthias Langbein
wrote:
>Hi all,
>I decided to post the code, maybe someone can tell me why there is the
>exception...
>
>
>
>
>
>namespace MyOwnAddIn
>{
> using System;
> using Microsoft.Office.Core;
> using Extensibility;
> using System.Runtime.InteropServices;
> using Word = Microsoft.Office.Interop.Word;
>
>[GuidAttribute("715D48EE-9F94-4055-AC62-4D22E89913AD"),
> ProgId("MyOwnAddIn.Connect")]
>
> public class Connect : Object, Extensibility.IDTExtensibility2
> {
> public Connect()
> {
> }
>
> public void OnConnection(object application,
> Extensibility.ext_ConnectMode connectMode, object addInInst,
> ref System.Array custom)
> {
> applicationObject = application;
> addInInstance = addInInst;
> if (application is Word.Application)
> { wordApp = (Word.Application)application; }
> Microsoft.Office.Core.CommandBar toolBar = null;
> if (wordApp != null)
> { toolBar = AddWordToolbar(wordApp, "Some useful toolbar."); }
> }
>
> public void OnDisconnection(Extensibility.ext_DisconnectMode
> disconnectMode, ref System.Array custom)
> {
> }
>
> public void OnAddInsUpdate(ref System.Array custom)
> {
> }
>
> public void OnStartupComplete(ref System.Array custom)
> {
> }
>
> public void OnBeginShutdown(ref System.Array custom)
> {
> }
>
> private Microsoft.Office.Core.CommandBar
> AddWordToolbar(Word.Application word, string toolbarName)
> {
> Microsoft.Office.Core.CommandBar toolBar = null;
> try
> {
> object missing = System.Reflection.Missing.Value;
> toolBar = (Microsoft.Office.Core.CommandBar)
> wordApp.CommandBars.Add(toolbarName,
> Microsoft.Office.Core.MsoBarPosition.msoBarTop,
> missing, true );
> toolBar.Visible = true;
> return toolBar;
> }
> catch (Exception ee)
> {
> System.Windows.Forms.MessageBox.Show(ee.Message);
> return null;
> }
> }
>
> private object applicationObject;
> private object addInInstance;
> private Word.Application wordApp = null;
>}
>}
date: Wed, 26 Oct 2005 02:56:26 +0200
author: Matthias Langbein
Re: Exception when adding a toolbar as a word-addin
Yes, it has something to do with that error message.
I had the same problem. The resolution was to correct my reference to point
to the office.dll in the GAC and make sure I didn't have references to any
other versions of the office.dll
HTH
--
- B@rney
___________________________
http://www.sharepointdemo.biz/
http://www.sharepointdemo.biz/blogs/bjarne/
"Matthias Langbein" wrote:
> I get the warning:
>
> 'Microsoft.Office.Core.CommandBar' is defined in multiple places;
> using definition from
> 'c:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\office.dll'
>
> Might this have anything to do with it? And how do I solve this
> problem?
>
>
> On Tue, 25 Oct 2005 22:12:15 +0200, Matthias Langbein
> wrote:
>
> >Hi all,
> >I decided to post the code, maybe someone can tell me why there is the
> >exception...
> >
> >
> >
> >
> >
> >namespace MyOwnAddIn
> >{
> > using System;
> > using Microsoft.Office.Core;
> > using Extensibility;
> > using System.Runtime.InteropServices;
> > using Word = Microsoft.Office.Interop.Word;
> >
> >[GuidAttribute("715D48EE-9F94-4055-AC62-4D22E89913AD"),
> > ProgId("MyOwnAddIn.Connect")]
> >
> > public class Connect : Object, Extensibility.IDTExtensibility2
> > {
> > public Connect()
> > {
> > }
> >
> > public void OnConnection(object application,
> > Extensibility.ext_ConnectMode connectMode, object addInInst,
> > ref System.Array custom)
> > {
> > applicationObject = application;
> > addInInstance = addInInst;
> > if (application is Word.Application)
> > { wordApp = (Word.Application)application; }
> > Microsoft.Office.Core.CommandBar toolBar = null;
> > if (wordApp != null)
> > { toolBar = AddWordToolbar(wordApp, "Some useful toolbar."); }
> > }
> >
> > public void OnDisconnection(Extensibility.ext_DisconnectMode
> > disconnectMode, ref System.Array custom)
> > {
> > }
> >
> > public void OnAddInsUpdate(ref System.Array custom)
> > {
> > }
> >
> > public void OnStartupComplete(ref System.Array custom)
> > {
> > }
> >
> > public void OnBeginShutdown(ref System.Array custom)
> > {
> > }
> >
> > private Microsoft.Office.Core.CommandBar
> > AddWordToolbar(Word.Application word, string toolbarName)
> > {
> > Microsoft.Office.Core.CommandBar toolBar = null;
> > try
> > {
> > object missing = System.Reflection.Missing.Value;
> > toolBar = (Microsoft.Office.Core.CommandBar)
> > wordApp.CommandBars.Add(toolbarName,
> > Microsoft.Office.Core.MsoBarPosition.msoBarTop,
> > missing, true );
> > toolBar.Visible = true;
> > return toolBar;
> > }
> > catch (Exception ee)
> > {
> > System.Windows.Forms.MessageBox.Show(ee.Message);
> > return null;
> > }
> > }
> >
> > private object applicationObject;
> > private object addInInstance;
> > private Word.Application wordApp = null;
> >}
> >}
>
>
date: Thu, 3 Nov 2005 03:02:04 -0800
author: - B@rney
|
|