This project has moved. For the latest updates, please go here.

Cannot find the NetOffice equivalent for Microsoft.Office.Tools (.Excel.Controls)

Feb 11, 2014 at 6:15 PM
Hello Sebastian,

unfortunately I cannot find the NetOffice references/equivalents for:
  • Microsoft.Office.Tools
  • Microsoft.Office.Tools.Excel
  • Microsoft.Office.Tools.Excel.Controls
Can you give me a hint!?

Many thanks in advance!

Best regards,
Rainer
Feb 14, 2014 at 12:44 PM
Hello,

anyone there who has an idea, where to find the Microsoft.Office.Tools - equivalents in NetOffice? Or does NetOffice NOT support these types of libraries?

I am trying to transform an Excel-COM-Addin from VSTO/PIA to NetOffice, but this it at the moment a big obstacle. There are controls like diagrams, buttons etc. which I insert via code automatically to the Excel-sheets.

Many many thanks in advance for your help!
Rainer
Coordinator
Feb 14, 2014 at 10:04 PM
it's true, NetOffice doesnt have an equivalent for the tools namespace because this is a VSTO.NET special top-of feature(its not spend from office himself). NO is a jsut a plain 1:1 wrapper for the COM automation interface. anyway, the tools namespace does no magic, just a wrapper to do the all the things a bit easier. please explain, whats your problem and may we can help.

Sebastian

(btw: we work for more VSTO support today, but its quiet challenging for all the different office products)
Feb 20, 2014 at 6:27 AM
Hello Sebastian,

many thanks for your explanations. You have my full respect regarding the fine piece of work you have done!

The MS.Office.Tools namespace offers additional features, which are not available in the interop namespace (as far as I know). Especially the possibilities to place controls like buttons and charts onto an excel worksheet are very nice features. Below is one simple example:
 '========================================================
    ' FORMAT TEXT-TO-VALUE (LEAVE TEXTBOX)
    '  - Zahlenformat für Preis anpassen
    '========================================================
    Private Sub FormatTextToValue_Leave()

        'Worksheet als "Tools.Excel" anstatt "Interop.Excel" damit später "Controls" dynamisch erstellt werden können !!!
        Dim xlWorksheet As Microsoft.Office.Tools.Excel.Worksheet = Nothing
        Dim txtPriceChange As Microsoft.Office.Tools.Excel.Controls.TextBox

        '' Arbeitsblatt als "Tools.Excel.Worksheet" zuweisen, damit .Controls.AddNamedRange verwendet werden kann.
'' Umwandeln von Interop.Excel.Worksheet zu Tools.Excel.Worksheet (um dadurch auf höhere Funktionalität zuzugreifen 
        xlWorksheet = Microsoft.Office.Tools.Excel.Worksheet.GetVstoObject(xlOverview)  
        txtPriceChange = xlWorksheet.Controls.Item("txtChangePrice")

        txtPriceChange.Text = FormatValue(txtPriceChange.Text, "###,###,##0.00")
        If txtPriceChange.Text = "" Then
            txtPriceChange.Text = FormatValue(xlGeneral.Range(xclsECV_InputCalc._GeFPri).Value, "###,###,##0.00")
        End If

    End Sub
If you have any other idea how to place and use controls with NetOffice to an Excel worksheet, I would be very very happy!

Many thanks!!!
Rainer

P.S.: I am really looking forward for your RibbonDesigner (NetOffice 1.8) :-)
Feb 21, 2014 at 5:51 AM
I have added command buttons with click event handlers using C# code similar to the following. I asssume that other control types can be added in a similar way. You must add references to Microsoft.Vbe.Interop.Forms and Microsoft.VisualBasic to your project.


using Microsoft.VisualBasic.CompilerServices;
using MSForms = Microsoft.Vbe.Interop.Forms;
using Excel = NetOffice.ExcelApi;

....

// sheet is an Excel.Worksheet instance

Excel.Shape cmdButton = (Excel.Shape)sheet.Shapes.AddOLEObject("Forms.CommandButton.1", Type.Missing, false, false, Type.Missing, Type.Missing, Type.Missing, 200, 100, 100, 100);
cmdButton.Name = "btnClick";
dynamic dynCmdBtn = NewLateBinding.LateGet(sheet.UnderlyingObject, null, "btnClick", new object[0], null, null, null);
dynCmdBtn.Caption = "My Button";
dynCmdBtn.Click += new MSForms.CommandButtonEvents_ClickEventHandler(CmdBtn_Click);


....


void CmdBtn_Click()
{
        MessageBox.Show("CmdBtn_Click");
}
Jun 20, 2014 at 4:30 AM
Hi,

Is it possible to expand a bit more on this answer? Is it possible to learn more about what the tools namespace wrapper does?

I am trying to understand that if NetOffice doesn't support Tools namespace functionality directly, then how do I go about learning more details and do controls-related stuff without going through this wrapper.

Any relevant documentation / examples please?

Regards.
Jun 20, 2014 at 4:32 AM
Hi rixeblitz,

Wanted to check if you could eventually get the controls-stuff working through NetOffice somehow, and if yes / possible, share some details please.

Was the approach suggested by geirg earlier in this thread of any use in this context?

Regards.
Jun 24, 2014 at 3:35 PM
Hi dd1985,

actually I have not realized the proposal due to the fact that I have too many Microsoft.Office.Tools - Controls in use - so many that a workaround for me as a non-software-engineer would be too complex. I would love to use Net Office, but I am depending on the MS.Office.Tools, which I have understood, are not directly covered by NetOffice. Nevertheless I am following the evolution of Net Office and hope that in the future also Office.Tools are included. Most Office-developers probably do not need MS.Office.Tools can be delighted to use such a perfect software as NetOffice to avoid the vendor-lock-in.

Sorry, for not giving you software details neither being able to report any experiences with the above code snippets.

Best regards,
Rixeblitz