phani kumar ---help me out

Hi,

I have created an office 2003 addin with teh code given in the site

http://msdn2.microsoft.com/en-gb/library/aa218648(office.11).aspx

but the addin is being created and i was not able to get the addin with the frontpage.

When i tried to manually add the addin to the front page it is giving an error saying invalid office addin.

please help me i have no time......

Thanks,

phani

In advance




Re: Visual Studio Extensibility Problem with the office 2003 addin

phani kumar ---help me out

Is anybody watching this forum or not.............




Re: Visual Studio Extensibility Problem with the office 2003 addin

Carlos Quintero - MVP

Yes, there is people watching but this forum is not really for Office extensibility and second you don't provide much info about the error. Which is the exact error that you are getting Is there a numeric COM error Are you using exception handlers

I have created a new Shared Add-In for Frontpage using VB.NET 2003 with this connect class:

Public Sub OnConnection(ByVal application As Object, ByVal connectMode As Extensibility.ext_ConnectMode, ByVal addInInst As Object, ByRef custom As System.Array) Implements Extensibility.IDTExtensibility2.OnConnection

System.Windows.Forms.MessageBox.Show(application.ToString)

End Sub

and while I get an error when trying to launch frontpage instead of Visual Studio to debug it, and I can't attach to a running FrontPage instance, when I compile it and I run FrontPage separately, the add-in is loaded and I get the message box. So, create a new Shared addin for Frontpage using the wizard, ensure that it gets loaded in FrontPage and then study the differences with the add-in failing.






Re: Visual Studio Extensibility Problem with the office 2003 addin

Carlos Quintero - MVP

See also:

PRB: Visual Studio .NET Shared Add-in Is Not Displayed in Office COM Add-ins Dialog Box

http://support.microsoft.com/default.aspx scid=kb%3bEN-US%3bq316723






Re: Visual Studio Extensibility Problem with the office 2003 addin

phani kumar ---help me out

Thanks Carlos,

Sorry for that previous post i was a bit unstable these days due to this addin.I have tried with this link earlier only.Th eproblem is the same that was given in this page but their work around have not worked for me. May be i have missed something.

And regarding posting here as iam using extensibility in my app i thought it will be the right area.Any how if this is not right can you please give me the link for the right place where i can find any solution.

Iam getting teh error saying "office addin path" is not a valid office addin".

This error is occuring while iam running it from code or after installing.I was in such a frustration as the client is on my head calling daily abt progress.

Sorry carlos,

Please help me out..............






Re: Visual Studio Extensibility Problem with the office 2003 addin

Carlos Quintero - MVP

Hi,

1) Does the add-in run on your machine If no, create two new Shared addins for Frontpage, one for all users, and other for current user, and see if they work (they should).

2) Does the add-in only fail on the client machine In such case, is the add-in COM-registered Is it Frontpage-registered as add-in Is the add-in disabled (see the disabled items in the About window)






Re: Visual Studio Extensibility Problem with the office 2003 addin

phani kumar ---help me out

Thanks for the reply Carlos,

I have created both the addins but they havenot worked in my machine not only in my machine i tried out in 5 more machines creating them both

it have not worked iam sending the code i have used to generate both the addins please check it and let me know what i have missed....

namespace FPAddin
{
using System;
using Extensibility;
using System.Runtime.InteropServices;
using Microsoft.Office.Core;
using Microsoft.Office;
using System.Windows.Forms;
using System.Reflection;

#region Read me for Add-in installation and setup information.
// When run, the Add-in wizard prepared the registry for the Add-in.
// At a later time, if the Add-in becomes unavailable for reasons such as:
// 1) You moved this project to a computer other than which is was originally created on.
// 2) You chose 'Yes' when presented with a message asking if you wish to remove the Add-in.
// 3) Registry corruption.
// you will need to re-register the Add-in by building the FPAddinSetup project,
// right click the project in the Solution Explorer, then choose install.
#endregion

/// <summary>
/// The object for implementing an Add-in.
/// </summary>
/// <seealso class='IDTExtensibility2' />
[GuidAttribute("773C8668-8666-465D-8F96-3698B8F00F11"), ProgId("FPAddin.Connect")]
public class Connect : Object, Extensibility.IDTExtensibility2
{
/// <summary>
/// Implements the constructor for the Add-in object.
/// Place your initialization code within this method.
/// </summary>
private CommandBarButton MyButton;
public Connect()
{
}

/// <summary>
/// Implements the OnConnection method of the IDTExtensibility2 interface.
/// Receives notification that the Add-in is being loaded.
/// </summary>
/// <param term='application'>
/// Root object of the host application.
/// </param>
/// <param term='connectMode'>
/// Describes how the Add-in is being loaded.
/// </param>
/// <param term='addInInst'>
/// Object representing this Add-in.
/// </param>
/// <seealso class='IDTExtensibility2' />
public void OnConnection(object application, Extensibility.ext_ConnectMode connectMode, object addInInst, ref System.Array custom)
{
applicationObject = application;
addInInstance = addInInst;
if (connectMode != Extensibility.ext_ConnectMode.ext_cm_Startup)
{
OnStartupComplete(ref custom);
}

}

/// <summary>
/// Implements the OnDisconnection method of the IDTExtensibility2 interface.
/// Receives notification that the Add-in is being unloaded.
/// </summary>
/// <param term='disconnectMode'>
/// Describes how the Add-in is being unloaded.
/// </param>
/// <param term='custom'>
/// Array of parameters that are host application specific.
/// </param>
/// <seealso class='IDTExtensibility2' />
public void OnDisconnection(Extensibility.ext_DisconnectMode disconnectMode, ref System.Array custom)
{
if (disconnectMode != Extensibility.ext_DisconnectMode.ext_dm_HostShutdown)
{
OnBeginShutdown(ref custom);
}
applicationObject = null;

}

/// <summary>
/// Implements the OnAddInsUpdate method of the IDTExtensibility2 interface.
/// Receives notification that the collection of Add-ins has changed.
/// </summary>
/// <param term='custom'>
/// Array of parameters that are host application specific.
/// </param>
/// <seealso class='IDTExtensibility2' />
public void OnAddInsUpdate(ref System.Array custom)
{
}

/// <summary>
/// Implements the OnStartupComplete method of the IDTExtensibility2 interface.
/// Receives notification that the host application has completed loading.
/// </summary>
/// <param term='custom'>
/// Array of parameters that are host application specific.
/// </param>
/// <seealso class='IDTExtensibility2' />
public void OnStartupComplete(ref System.Array custom)
{
CommandBars oCommandBars;
CommandBar oStandardBar;

try
{
oCommandBars = (CommandBars)applicationObject.GetType().InvokeMember("CommandBars", BindingFlags.GetProperty, null, applicationObject, null);
}
catch (Exception)
{
// Outlook has the CommandBars collection on the Explorer object.
object oActiveExplorer;
oActiveExplorer = applicationObject.GetType().InvokeMember("ActiveExplorer", BindingFlags.GetProperty, null, applicationObject, null);
oCommandBars = (CommandBars)oActiveExplorer.GetType().InvokeMember("CommandBars", BindingFlags.GetProperty, null, oActiveExplorer, null);
}

// Set up a custom button on the "Standard" commandbar.
try
{
oStandardBar = oCommandBars["Standard"];
}
catch (Exception)
{
// Access names its main toolbar Database.
oStandardBar = oCommandBars["Database"];
}

// In case the button was not deleted, use the exiting one.
try
{
MyButton = (CommandBarButton)oStandardBar.Controls["My Custom Button"];
}
catch (Exception)
{
object omissing = System.Reflection.Missing.Value;
MyButton = (CommandBarButton)oStandardBar.Controls.Add(1, omissing, omissing, omissing, omissing);
MyButton.Caption = "My Custom Button";
MyButton.Style = MsoButtonStyle.msoButtonCaption;
}

// The following items are optional, but recommended.
//The Tag property lets you quickly find the control
//and helps MSO keep track of it when more than
//one application window is visible. The property is required
//by some Office applications and should be provided.
MyButton.Tag = "My Custom Button";

// The OnAction property is optional but recommended.
//It should be set to the ProgID of the add-in, so that if
//the add-in is not loaded when a user presses the button,
//MSO loads the add-in automatically and then raises
//the Click event for the add-in to handle.
MyButton.OnAction = "!<MyCOMAddin.Connect>";

MyButton.Visible = true;
MyButton.Click += new Microsoft.Office.Core._CommandBarButtonEvents_ClickEventHandler(this.MyButton_Click);


object oName = applicationObject.GetType().InvokeMember("Name", BindingFlags.GetProperty, null, applicationObject, null);

// Display a simple message to show which application you started in.
System.Windows.Forms.MessageBox.Show("This Addin is loaded by " + oName.ToString(), "MyCOMAddin");
oStandardBar = null;
oCommandBars = null;


}

/// <summary>
/// Implements the OnBeginShutdown method of the IDTExtensibility2 interface.
/// Receives notification that the host application is being unloaded.
/// </summary>
/// <param term='custom'>
/// Array of parameters that are host application specific.
/// </param>
/// <seealso class='IDTExtensibility2' />
public void OnBeginShutdown(ref System.Array custom)
{
object omissing = System.Reflection.Missing.Value;
System.Windows.Forms.MessageBox.Show("MyCOMAddin Add-in is unloading.");
MyButton.Delete(omissing);
MyButton = null;

}
private void MyButton_Click(CommandBarButton cmdBarbutton, ref bool cancel)
{
System.Windows.Forms.MessageBox.Show("MyButton was Clicked", "MyCOMAddin");
}

private object applicationObject;
private object addInInstance;
}
}

and also tried with another code that is used to read the data into a winform

namespace SHaredAddin1
{
using System;
using Microsoft.Office.Core;
using Extensibility;
using System.Runtime.InteropServices;
using System.Reflection;
using Office = Microsoft.Office.Core;
using fpWeb = Microsoft.Office.Interop.FrontPage;
using fpPage = Microsoft.Office.Interop.FrontPageEditor;
using System.Windows.Forms;

#region Read me for Add-in installation and setup information.
// When run, the Add-in wizard prepared the registry for the Add-in.
// At a later time, if the Add-in becomes unavailable for reasons such as:
// 1) You moved this project to a computer other than which is was originally created on.
// 2) You chose 'Yes' when presented with a message asking if you wish to remove the Add-in.
// 3) Registry corruption.
// you will need to re-register the Add-in by building the SHaredAddin1Setup project,
// right click the project in the Solution Explorer, then choose install.
#endregion

/// <summary>
/// The object for implementing an Add-in.
/// </summary>
/// <seealso class='IDTExtensibility2' />
[GuidAttribute("0EF9C4C3-EFE4-47CD-8D1D-5AD7F44F06BC"), ProgId("SHaredAddin1.Connect")]
public class Connect : Object, Extensibility.IDTExtensibility2
{
//Global FrontPage application object.
private object applicationObject;
private object addInInstance;
private fpWeb.Application appFP;
private CommandBarButton button;

/// <summary>
/// Implements the constructor for the Add-in object.
/// Place your initialization code within this method.
/// </summary>
public Connect()
{
}

/// <summary>
/// Implements the OnConnection method of the IDTExtensibility2 interface.
/// Receives notification that the Add-in is being loaded.
/// </summary>
/// <param name='application'>
/// Root object of the host application.
/// </param>
/// <param name='connectMode'>
/// Describes how the Add-in is being loaded.
/// </param>
/// <param name='addInInst'>
/// Object representing this Add-in.
/// </param>
/// <param name='custom'>
/// Array of parameters that are host application specific.
/// </param>
/// <seealso class='IDTExtensibility2' />
public void OnConnection(object application, Extensibility.ext_ConnectMode connectMode, object addInInst, ref System.Array custom)
{
this.applicationObject = application;
this.addInInstance = addInInst;
this.appFP = (fpWeb.Application)this.applicationObject;
}

/// <summary>
/// Implements the OnAddInsUpdate method of the IDTExtensibility2 interface.
/// Receives notification that the collection of Add-ins has changed.
/// </summary>
/// <param name='custom'>
/// Array of parameters that are host application specific.
/// </param>
/// <seealso class='IDTExtensibility2' />
public void OnAddInsUpdate(ref System.Array custom)
{
}

/// <summary>
/// Implements the OnStartupComplete method of the IDTExtensibility2 interface.
/// Receives notification that the host application has completed loading.
/// </summary>
/// <param name='custom'>
/// Array of parameters that are host application specific.
/// </param>
/// <seealso class='IDTExtensibility2' />
public void OnStartupComplete(ref System.Array custom)
{
CommandBars commandBars;
CommandBar standardCommandBar;
object optional = System.Reflection.Missing.Value;

//Adds events handlers to manage enabling and disabling the toolbar button.
this.appFP.OnPageWindowActivate += new Microsoft.Office.Interop.FrontPage._IApplicationEvents_OnPageWindowActivateEventHandler(this.EnableButton);
this.appFP.OnPageClose += new Microsoft.Office.Interop.FrontPage._IApplicationEvents_OnPageCloseEventHandler(this.DisableButton);

try
{
//Access the CommandBars collection for the application.
commandBars = (CommandBars)this.applicationObject.GetType().InvokeMember("CommandBars", BindingFlags.GetProperty, null, this.applicationObject, null);

//Access the Standard Command Bar and add a button control to it.
standardCommandBar = commandBars["Standard"];
this.button = (Office.CommandBarButton)standardCommandBar.Controls.Add(MsoControlType.msoControlButton, optional, optional, optional, optional);

//Format the Button control.
this.button.Style = MsoButtonStyle.msoButtonCaption;
this.button.Caption = "Insert Image";
this.button.Tag = this.button.Caption;
this.button.Visible = true;
this.button.BeginGroup = true;

//Button is disabled initially. Button is enabled when a Web site is opened.
this.button.Enabled = false;

//Add a click event to the button control.
this.button.Click += new Office._CommandBarButtonEvents_ClickEventHandler(this.OpenDialogBox);
}
catch (Exception err)
{
MessageBox.Show(err.Message);
}
}

/// <summary>
/// Implements the OnDisconnection method of the IDTExtensibility2 interface.
/// Receives notification that the Add-in is being unloaded.
/// </summary>
/// <param name='disconnectMode'>
/// Describes how the Add-in is being unloaded.
/// </param>
/// <param name='custom'>
/// Array of parameters that are host application specific.
/// </param>
/// <seealso class='IDTExtensibility2' />
public void OnDisconnection(Extensibility.ext_DisconnectMode disconnectMode, ref System.Array custom)
{
try
{
//Delete the button on the toolbar.
object optional = System.Reflection.Missing.Value;
this.button.Delete(optional);
this.button = null;
optional = null;

//Explicitly destroy all application object variables.
this.appFP = null;
this.applicationObject = null;
this.addInInstance = null;
System.GC.Collect();
}
catch (Exception err)
{
MessageBox.Show(err.Message);
}
}

/// <summary>
/// Implements the OnBeginShutdown method of the IDTExtensibility2 interface.
/// Receives notification that the host application is being unloaded.
/// </summary>
/// <param name='custom'>
/// Array of parameters that are host application specific.
/// </param>
/// <seealso class='IDTExtensibility2' />
///
public void OnBeginShutdown(ref System.Array custom)
{
}

/// <summary>
/// Enables button on new or open page event.
/// </summary>
/// <param name='page'>
/// Specifies the current FrontPage page window.
/// </param>
public void EnableButton(fpWeb.PageWindowEx page)
{
if (this.appFP.ActiveWeb != null)
{
this.button.Enabled = true;
}
}

/// <summary>
/// Disables button if it's enabled on page close event.
/// </summary>
/// <param name='page'>
/// Specifies the current FrontPage Page window.
/// </param>
/// <param name='cancel'>
/// Specifies whether the user clicked bCancel.
/// </param>
public void DisableButton(fpWeb.PageWindowEx page, ref bool cancel)
{
if (this.button.Enabled == true)
{
this.button.Enabled = false;
}
}

/// <summary>
/// Opens the custom Insert Image dialog box.
/// </summary>
/// <param name='button'>
/// Specifies the command bar button that is clicked.
/// </param>
/// <param name='cancel'>
/// Specifies whether the user clicked bCancel.
/// </param>
public void OpenDialogBox(CommandBarButton button, ref bool cancel)
{
fpPage.FPHTMLDocument objDoc = appFP.ActivePageWindow.ActiveDocument;
try
{
this.appFP.ActiveDocument.parseCodeChanges();
InsertImageForm frmNew = new InsertImageForm(this.appFP.Application);

if (frmNew.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
try
{
//Parse code changes and attempt to paste HTML string
//into current document at the insertion point.
objDoc.parseCodeChanges();
fpPage.IHTMLTxtRange objRange = (fpPage.IHTMLTxtRange)objDoc.selection.createRange();
objRange.pasteHTML(frmNew.ImageHTML);
}
catch
{
//If unable to paste HTML into code view, copy to clipboard.
this.CopyToClipboard(frmNew.ImageHTML);

MessageBox.Show("You need to save your page first.\n\n" +
"HTML code has been placed in the clipboard. Save the \n" +
"page and then paste the image into the page in Code view.");
}

}
}
catch (Exception err)
{
MessageBox.Show(err.Message);
}
}

/// <summary>
/// Copies string to the Windows clipboard so that user can paste manually.
/// </summary>
/// <param name="text">Specifies the text to copy to the clipboard.</param>
private void CopyToClipboard(string text)
{
try
{
Clipboard.SetDataObject(text);
}
catch (Exception err)
{
MessageBox.Show(err.Message);
}
}
}
}

both of these have not worked please help me out






Re: Visual Studio Extensibility Problem with the office 2003 addin

Carlos Quintero - MVP

The code is correct, it worked for me, I get FrontPage with a "My Custom Button" on the Standard toolbar and when clicked I get the message "MyButton was Clicked".

I still don't know which is your problem. Getting back to your first post you said:

"but the addin is being created and i was not able to get the addin with the frontpage. When i tried to manually add the addin to the front page it is giving an error saying invalid office addin."

Notice that there are not one but two problems there.

Question: when you run the wizard of Visual Studio .NET 2003 to generate a Shared Add-in for Frontpage, what options (checked/uncheked) do you select in page 4 of 5 for these options:

- "I would like my add-in to load when the host application loads". Hint: I checked this checkbox.

- "My add-in should be available to all users of the computer...." Hint: I did NOT check this checkbox.






Re: Visual Studio Extensibility Problem with the office 2003 addin

phani kumar ---help me out

Thanks Radvis,

The first thing is iam using VS2005 for the development of addin.....

Next In the 4 of 5 screen I tried all the possible 4 combinations but still the addin is not working in FP2003 it worked fine for FP2000

I was unbale to know the reason why........Also see the the code 2 It was given for creating Office2003 addin it also have not worked out......

Please help me






Re: Visual Studio Extensibility Problem with the office 2003 addin

Carlos Quintero - MVP

Try this:

FIX: Add-ins, smart documents, or smart tags that you create by using Microsoft Visual Studio 2005 do not run in Office

http://support.microsoft.com/kb/908002






Re: Visual Studio Extensibility Problem with the office 2003 addin

phani kumar ---help me out

I have tried this also......It didnt work.........Actually we got vexed up with this and also we lost our client's faith...

But anyway i still want the solution......Can you please help me out or send me that working dll so that i can test in my PC as well as client's PC if he agrees so that i can find if there is any thing wrong in my coding or my PC settings






Re: Visual Studio Extensibility Problem with the office 2003 addin

Carlos Quintero - MVP

Hi,

I am sorry to hear that it didn't fix the problem. I am out of ideas, all my knowledge about troubleshooting add-in problems is in this article that I wrote recently, mainly to summarize many answers that I was giving you:

HOWTO: Troubleshooting Visual Studio and Office add-ins
http://www.mztools.com/resources_office_addins.htm

Review it to see if there is something missing.