Quantcast
Channel: NetOffice - MS Office in .NET
Viewing all 1741 articles
Browse latest View live

New Post: Accessing table field properties such as "TextAlign" in Microsoft Access 2013

$
0
0
Hi Sebastian,

Thank you for your time and for looking into this issue. I am using NetOffice 1.6.0.0 and Microsoft Office 2013. Basically I am trying to get the values of properties such as "TextAlign", "Caption", "Description" from a table field in Microsoft Access. Do you have any examples of getting the values of these properties from a table field?

Thank you.
Dun

New Post: Excel: Apply a TableStyle to a QueryTable

$
0
0
I've just realised I can record a macro to record what happens when I use the GUI:
    With ActiveSheet.ListObjects.Add(SourceType:=0, Source:= _
        "ODBC;..." _
        , Destination:=Range("$A$1")).QueryTable
        .CommandText = Array("SELECT * FROM myTable")
        .RowNumbers = False
        .FillAdjacentFormulas = False
        .PreserveFormatting = True
        .RefreshOnFileOpen = False
        .BackgroundQuery = True
        .RefreshStyle = xlInsertDeleteCells
        .SavePassword = False
        .SaveData = True
        .AdjustColumnWidth = True
        .RefreshPeriod = 0
        .PreserveColumnInfo = True
        .ListObject.DisplayName = "Table_myTable"
        .Refresh BackgroundQuery:=False
    End With
However, I can't seem to replicate it via NetOffice and get the same result?
            var sheet = (_excel.ActiveSheet as Excel.Worksheet);
            var rng = sheet.Range("$A$1");

            var lo = sheet.ListObjects.Add(
                0,
                "ODBC;...",
                Missing.Value,
                Excel.Enums.XlYesNoGuess.xlNo,
                rng);

            var qt = lo.QueryTable;
            qt.CommandText = new[] { "SELECT TOP 1 * FROM myTable" };
            qt.RowNumbers = false;
            qt.FillAdjacentFormulas = false;
            qt.PreserveFormatting = true;
            qt.RefreshOnFileOpen = false;
            qt.BackgroundQuery = true;
            qt.RefreshStyle = Excel.Enums.XlCellInsertionMode.xlInsertDeleteCells;
            qt.SavePassword = false;
            qt.SaveData = true;
            qt.AdjustColumnWidth = true;
            qt.RefreshPeriod = 0;
            qt.PreserveColumnInfo = true;
            qt.ListObject.DisplayName = "Table_myTable";
            qt.Refresh();

Commented Unassigned: Permanent exception Class not exists: NetOffice.*Api.[ClassName] [20450]

$
0
0
We received this bug in few places. Usually it thrown in time of calling some classes instances like an IEnumerator, for example with LINQ methods. You could see one of them in example. Just launch app.
In this case we have "Class not exists: NetOffice.AccessApi.Property"
Could you propose fix of this bug type?
Comments: ** Comment from web user: dwallacetriad **

Are there any updates on this issue? We are trying to read properties of fields such as Text Align, Description, and Caption.

Thanks, Debbie

New Post: COM Exceptions with NetOffice

$
0
0
I'm trying to port an Excel VSTO Addin over to NetOffice. So far I've got the Addin launching, but any time I try to make a call on a NetOffice object I get the following:
----- Source: NetOffice -----
Inner Exception 1: System.MissingMethodException: Method 'System.__ComObject.Add' not found.
   at System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams)
   at NetOffice.Invoker.MethodReturn(COMObject comObject, String name, Object[] paramsArray)
System.Runtime.InteropServices.COMException: See inner exception(s) for details.
   at NetOffice.Invoker.MethodReturn(COMObject comObject, String name, Object[] paramsArray)
   at NetOffice.ExcelApi.Workbooks.Add()
   at Hcg.Stinger.Connect.InitializeAutomationAddIn() in D:\Code\Prevision\Source\Hcg\Stinger\Connect.cs:line 541
   at Hcg.Stinger.Connect.OnStartupComplete(Array& custom, MainTaskPane taskPane) in D:\Code\Prevision\Source\Hcg\Stinger\Connect.cs:line 258
----------
The code is pretty straightforward:
Excel.Workbook  book = _excelApp.Workbooks.Add();
I also got the similar error when I called saying the Cursor did not exist, even though it show up in the intellisense:
Excel.Enums.XlMousePointer cursorOriginal = Excel.Enums.XlMousePointer.xlDefault;
_excelApp.Cursor = Excel.Enums.XlMousePointer.xlWait;
Ideas?

Thanks,

Erick

Created Unassigned: COM Exceptions in NetOffice (Excel) [21030]

$
0
0
I'm trying to port an Excel VSTO Addin over to NetOffice. So far I've got the Addin launching, but any time I try to make a call on a NetOffice object I get the following:
```
----- Source: NetOffice -----
Inner Exception 1: System.MissingMethodException: Method 'System.__ComObject.Add' not found.
at System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams)
at NetOffice.Invoker.MethodReturn(COMObject comObject, String name, Object[] paramsArray)
System.Runtime.InteropServices.COMException: See inner exception(s) for details.
at NetOffice.Invoker.MethodReturn(COMObject comObject, String name, Object[] paramsArray)
at NetOffice.ExcelApi.Workbooks.Add()
at Hcg.Stinger.Connect.InitializeAutomationAddIn() in D:\Code\Prevision\Source\Hcg\Stinger\Connect.cs:line 541
at Hcg.Stinger.Connect.OnStartupComplete(Array& custom, MainTaskPane taskPane) in D:\Code\Prevision\Source\Hcg\Stinger\Connect.cs:line 258
----------
```

The code is pretty straightforward:
```
Excel.Workbook book = _excelApp.Workbooks.Add();
```

I also got the similar error when I called saying the Cursor did not exist, even though it show up in the intellisense:
```
Excel.Enums.XlMousePointer cursorOriginal = Excel.Enums.XlMousePointer.xlDefault;
_excelApp.Cursor = Excel.Enums.XlMousePointer.xlWait;
```

Ideas?

Thanks,

Erick

Commented Unassigned: COM Exceptions in NetOffice (Excel) [21030]

$
0
0
I'm trying to port an Excel VSTO Addin over to NetOffice. So far I've got the Addin launching, but any time I try to make a call on a NetOffice object I get the following:
```
----- Source: NetOffice -----
Inner Exception 1: System.MissingMethodException: Method 'System.__ComObject.Add' not found.
at System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams)
at NetOffice.Invoker.MethodReturn(COMObject comObject, String name, Object[] paramsArray)
System.Runtime.InteropServices.COMException: See inner exception(s) for details.
at NetOffice.Invoker.MethodReturn(COMObject comObject, String name, Object[] paramsArray)
at NetOffice.ExcelApi.Workbooks.Add()
at Hcg.Stinger.Connect.InitializeAutomationAddIn() in D:\Code\Prevision\Source\Hcg\Stinger\Connect.cs:line 541
at Hcg.Stinger.Connect.OnStartupComplete(Array& custom, MainTaskPane taskPane) in D:\Code\Prevision\Source\Hcg\Stinger\Connect.cs:line 258
----------
```

The code is pretty straightforward:
```
Excel.Workbook book = _excelApp.Workbooks.Add();
```

I also got the similar error when I called saying the Cursor did not exist, even though it show up in the intellisense:
```
Excel.Enums.XlMousePointer cursorOriginal = Excel.Enums.XlMousePointer.xlDefault;
_excelApp.Cursor = Excel.Enums.XlMousePointer.xlWait;
```

Ideas?

Thanks,

Erick
Comments: ** Comment from web user: SebastianDotNet **

what i need to know:

1) Excel version(32 or 64 bit)
2) NetOffice version
3) Operating system(32 or 64 bit)

at last: the operating system is a developer machine or just a user pc.

the fast way to pin point the problem is a sample solution. (send to public[at]sebastian.web.de and remove any private code, i dont need this)

*Sebastian

Commented Unassigned: COM Exceptions in NetOffice (Excel) [21030]

$
0
0
I'm trying to port an Excel VSTO Addin over to NetOffice. So far I've got the Addin launching, but any time I try to make a call on a NetOffice object I get the following:
```
----- Source: NetOffice -----
Inner Exception 1: System.MissingMethodException: Method 'System.__ComObject.Add' not found.
at System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams)
at NetOffice.Invoker.MethodReturn(COMObject comObject, String name, Object[] paramsArray)
System.Runtime.InteropServices.COMException: See inner exception(s) for details.
at NetOffice.Invoker.MethodReturn(COMObject comObject, String name, Object[] paramsArray)
at NetOffice.ExcelApi.Workbooks.Add()
at Hcg.Stinger.Connect.InitializeAutomationAddIn() in D:\Code\Prevision\Source\Hcg\Stinger\Connect.cs:line 541
at Hcg.Stinger.Connect.OnStartupComplete(Array& custom, MainTaskPane taskPane) in D:\Code\Prevision\Source\Hcg\Stinger\Connect.cs:line 258
----------
```

The code is pretty straightforward:
```
Excel.Workbook book = _excelApp.Workbooks.Add();
```

I also got the similar error when I called saying the Cursor did not exist, even though it show up in the intellisense:
```
Excel.Enums.XlMousePointer cursorOriginal = Excel.Enums.XlMousePointer.xlDefault;
_excelApp.Cursor = Excel.Enums.XlMousePointer.xlWait;
```

Ideas?

Thanks,

Erick
Comments: ** Comment from web user: ericklind **

Actually I did get it working. I'm on Excel 2010 32 bit, VS 2010, .NET 4.0, NetOffice version 1.6, and Win 7 64 bit.
But now I'm getting other COM issues when I try to access other things like the taskPane:
```
Inner Exception 1: System.Runtime.InteropServices.InvalidComObjectException: Attempt has been made to use a COM object that does not have a backing class factory.
at NetOffice.Invoker.PropertySet(COMObject comObject, String name, Object[] value)
System.Runtime.InteropServices.COMException: See inner exception(s) for details.
at NetOffice.Invoker.PropertySet(COMObject comObject, String name, Object[] value)
at NetOffice.OfficeApi._CustomTaskPane.set_Visible(Boolean value)
at PrevisionAddIn.Addin.ShowExcelTaskPane(UserControl taskPane, String title) in D:\Code\Prevision\Source\Hcg\Stinger\PrevisionAddIn\Addin.cs:line 139
at Hcg.Stinger.TaskPaneFrameController.ShowController(ITaskPaneController controller) in D:\Code\Prevision\Source\Hcg\Stinger\TaskPaneFrameController.cs:line 332
at Hcg.Stinger.TaskPaneFrameController.Show(EnumGlobalTaskPanes taskPane) in D:\Code\Prevision\Source\Hcg\Stinger\TaskPaneFrameController.cs:line 146
at Hcg.Stinger.TaskPaneFrameController.AuthorizeTaskPanes() in D:\Code\Prevision\Source\Hcg\Stinger\TaskPaneFrameController.cs:line 174
at Hcg.Stinger.TaskPaneFrameController..ctor(MainTaskPane frame) in D:\Code\Prevision\Source\Hcg\Stinger\TaskPaneFrameController.cs:line 83
at Hcg.Stinger.Connect.OnStartupComplete(Array& custom, MainTaskPane taskPane) in D:\Code\Prevision\Source\Hcg\Stinger\Connect.cs:line 264
----------

```

So the the code is pretty straight forward:
```
private Office._CustomTaskPane _taskPane = null;

public void CTPFactoryAvailable(object CTPFactoryInst)
{
try
{
Office.ICTPFactory ctpFactory = new NetOffice.OfficeApi.ICTPFactory(_app, CTPFactoryInst);
_taskPane = ctpFactory.CreateCTP("Hcg.Stinger.MainTaskPane", "PrevisionEPM", Type.Missing);
_taskPane.DockPosition = MsoCTPDockPosition.msoCTPDockPositionRight;
_taskPane.DockPositionRestrict = MsoCTPDockPositionRestrict.msoCTPDockPositionRestrictNoChange;
_taskPane.Width = 300;
_taskPane.Visible = true;
_mainTaskPane = _taskPane.ContentControl as MainTaskPane;
ctpFactory.Dispose();
}
catch (Exception exception)
{
string message = string.Format("An error occured.{0}{0}{1}", Environment.NewLine, exception.Message);
MessageBox.Show(message, _progId, MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
public void ShowExcelTaskPane(System.Windows.Forms.UserControl taskPane, string title)
{
_taskPane.Visible = false;
_taskPane.DockPosition = MsoCTPDockPosition.msoCTPDockPositionRight;
_taskPane.DockPositionRestrict = MsoCTPDockPositionRestrict.msoCTPDockPositionRestrictNoChange;
_taskPane.Visible = true;
}
```
It also sets my takspane so that none of the controls work on it at all. Anything I need to do?

Commented Unassigned: COM Exceptions in NetOffice (Excel) [21030]

$
0
0
I'm trying to port an Excel VSTO Addin over to NetOffice. So far I've got the Addin launching, but any time I try to make a call on a NetOffice object I get the following:
```
----- Source: NetOffice -----
Inner Exception 1: System.MissingMethodException: Method 'System.__ComObject.Add' not found.
at System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams)
at NetOffice.Invoker.MethodReturn(COMObject comObject, String name, Object[] paramsArray)
System.Runtime.InteropServices.COMException: See inner exception(s) for details.
at NetOffice.Invoker.MethodReturn(COMObject comObject, String name, Object[] paramsArray)
at NetOffice.ExcelApi.Workbooks.Add()
at Hcg.Stinger.Connect.InitializeAutomationAddIn() in D:\Code\Prevision\Source\Hcg\Stinger\Connect.cs:line 541
at Hcg.Stinger.Connect.OnStartupComplete(Array& custom, MainTaskPane taskPane) in D:\Code\Prevision\Source\Hcg\Stinger\Connect.cs:line 258
----------
```

The code is pretty straightforward:
```
Excel.Workbook book = _excelApp.Workbooks.Add();
```

I also got the similar error when I called saying the Cursor did not exist, even though it show up in the intellisense:
```
Excel.Enums.XlMousePointer cursorOriginal = Excel.Enums.XlMousePointer.xlDefault;
_excelApp.Cursor = Excel.Enums.XlMousePointer.xlWait;
```

Ideas?

Thanks,

Erick
Comments: ** Comment from web user: ericklind **

Hi Sebastian,
The Saga continues. I was finally able to get this doing what I needed to. I noticed that on the TaskPanes.Add it was not doing anything to set or create the TaskPaneInfo.Pane, which I need for my app. I changed the code to this, and it worked:
```
public Addin()
{
try
{
TaskPanes.Add(typeof(MainTaskPane), "Main Task Pane");
TaskPanes[0].DockPosition = MsoCTPDockPosition.msoCTPDockPositionRight;
TaskPanes[0].DockPositionRestrict = MsoCTPDockPositionRestrict.msoCTPDockPositionRestrictNoHorizontal;
TaskPanes[0].Width = 250;
TaskPanes[0].Visible = true;
TaskPanes[0].Arguments = new object[] { this };


this.OnStartupComplete += new OnStartupCompleteEventHandler(Addin_OnStartupComplete);
this.OnConnection += new OnConnectionEventHandler(Addin_OnConnection);
this.OnDisconnection += new OnDisconnectionEventHandler(Addin_OnDisconnection);
}
catch (Exception throwedException)
{
string details = string.Format("{1}{1}Details:{1}{1}{0}", throwedException.Message, Environment.NewLine);
MessageBox.Show("An error occured in OnAction: " + details, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}

public override void CTPFactoryAvailable(object CTPFactoryInst)
{
try
{
base.CTPFactoryAvailable(CTPFactoryInst);
_taskPane = TaskPanes[0];
_mainTaskPane = _taskPane.Pane.ContentControl as MainTaskPane;
}
catch (Exception exception)
{
string message = string.Format("An error occured.{0}{0}{1}", Environment.NewLine, exception.Message);
MessageBox.Show(message, _progId, MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
```
Now the problem is that my taskpane is frozen as if it's disabled. I cannot interact with any controls on it at all. I've checked the status and it is enabled. Is there something that I need to do in order to enable that otherwise? I've looked through the samples and nothing stands out.

Thanks again for all your work!

-Erick


Commented Unassigned: COM Exceptions in NetOffice (Excel) [21030]

$
0
0
I'm trying to port an Excel VSTO Addin over to NetOffice. So far I've got the Addin launching, but any time I try to make a call on a NetOffice object I get the following:
```
----- Source: NetOffice -----
Inner Exception 1: System.MissingMethodException: Method 'System.__ComObject.Add' not found.
at System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams)
at NetOffice.Invoker.MethodReturn(COMObject comObject, String name, Object[] paramsArray)
System.Runtime.InteropServices.COMException: See inner exception(s) for details.
at NetOffice.Invoker.MethodReturn(COMObject comObject, String name, Object[] paramsArray)
at NetOffice.ExcelApi.Workbooks.Add()
at Hcg.Stinger.Connect.InitializeAutomationAddIn() in D:\Code\Prevision\Source\Hcg\Stinger\Connect.cs:line 541
at Hcg.Stinger.Connect.OnStartupComplete(Array& custom, MainTaskPane taskPane) in D:\Code\Prevision\Source\Hcg\Stinger\Connect.cs:line 258
----------
```

The code is pretty straightforward:
```
Excel.Workbook book = _excelApp.Workbooks.Add();
```

I also got the similar error when I called saying the Cursor did not exist, even though it show up in the intellisense:
```
Excel.Enums.XlMousePointer cursorOriginal = Excel.Enums.XlMousePointer.xlDefault;
_excelApp.Cursor = Excel.Enums.XlMousePointer.xlWait;
```

Ideas?

Thanks,

Erick
Comments: ** Comment from web user: ericklind **

Finally figured it out. For some reason I have to attach all the events to the event handlers in the constructor of the task pane before I they will work. Not sure why this should matter but it does.

New Post: toggleButton / checkBox

$
0
0
I cannot get the "onAction" events to fire for toggleButton or checkBox controls in the UI.

onAction only works for button.

Any help?

New Post: Selection mode in Excel

$
0
0
Hello!
At first, thanks for this great lib!
I'm trying to create a function window like form in C#, but I can not find out how to turn excel into cell selection mode:
Image

Is this feature exposed or do I have to implement SheetSelectionChangeEvent by my self?

Thanks,
K

New Post: Application.Dispose

$
0
0
Hello

I have the following scenario.
  • Word is not running
  • I create a netoffice word Application object from an independent .NET application
  • open a document and make some manipulation from the .NET application
  • the manipulation from the .NET application is completed
  • the document must remain open and the user uses the document for what ever he wants to do
  • does I have to call Application.Dispose() on the Netoffice Wrapper in the independent .NET Application in this case or not?
thanks

New Post: Help for a Newbee

$
0
0
Hi,

We are exploring various technologies to migrate a .XLA addin written in VBA code to VB.NET.
I saw that NET office provides this feature of migration, can you please help me with documentation like getting started, creating samples etc from scratch.

Thanks
Guru

Created Unassigned: Com Exception when set cell values [21059]

$
0
0
Hi all

Following code (Example 1) work fine on Excel 2010/2013 x86, windows x64 but don't work on Excel 2010/2013 x86, windows x32:
```
public void RunExample()
{
// start excel and turn off msg boxes
Excel.Application excelApplication = new Excel.Application();
excelApplication.DisplayAlerts = false;

// add a new workbook
Excel.Workbook workBook = excelApplication.Workbooks.Add();
Excel.Worksheet workSheet = (Excel.Worksheet)workBook.Worksheets[1];

// draw back color and perform the BorderAround method
workSheet.Range("$B2:$B5").Interior.Color = ToDouble(Color.DarkGreen);
workSheet.Range("$B2:$B5").BorderAround(XlLineStyle.xlContinuous, XlBorderWeight.xlMedium, XlColorIndex.xlColorIndexAutomatic);

// draw back color and border the range explicitly
workSheet.Range("$D2:$D5").Interior.Color = ToDouble(Color.DarkGreen);
workSheet.Range("$D2:$D5").Borders[XlBordersIndex.xlInsideHorizontal].LineStyle = XlLineStyle.xlDouble;
workSheet.Range("$D2:$D5").Borders[XlBordersIndex.xlInsideHorizontal].Weight = 4;
workSheet.Range("$D2:$D5").Borders[XlBordersIndex.xlInsideHorizontal].Color = ToDouble(Color.Black);

workSheet.Cells[1, 1].Value = "We have 2 simple shapes created.";

decimal d1=(decimal) 1.0099;
decimal d2 = (decimal)10001;

try
{
// Error here:
workSheet.Cells[10, 2].Formula = string.Format("=*{0}*{1}", d1, d2);
}
catch (Exception e)
{

throw;
}


// save the book
string fileExtension = GetDefaultExtension(excelApplication);
string workbookFile = string.Format("{0}\\Example01{1}", _hostApplication.RootDirectory, fileExtension);
workBook.SaveAs(workbookFile);

// close excel and dispose reference
excelApplication.Quit();
excelApplication.Dispose();

// show dialog for the user(you!)
_hostApplication.ShowFinishDialog(null, workbookFile);
}
```

StackTrace = " at NetOffice.Invoker.PropertySet(COMObject comObject, String name, Object[] value)\r\n at NetOffice.ExcelApi.Range.set_Formula(Object value)\r\n at ExcelExamplesCS4.Example01.RunExample() in c:\\Users\\thangtx\\Desktop\\netoffice-106580\\Examples\\E...

New Post: XML enabled tag in Excel

$
0
0
Hi folks,

Does anyone know how to leverage the enabled="false"/"true" XML tag at runtime?

Or maybe a better question for the group, how do you toggle enabling/disabling buttons in an excel ribbon? Basic functionality would be when I am logged in the buttons are enabled, and when logged out, the other buttons are disabled.

Sample XML Ribbon for Excel:
<?xml version="1.0" encoding="utf-8" ?>
<customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui" onLoad="OnLoadRibbonUI">
<ribbon>
<tabs>
  <tab id="My.Addin" label="My Addin">
    <group id="group1" label="My Addin">
      <button id="aboutButton" label="About" onAction="OnClickAboutButton" />
      <button id="settingsButton" label="Settings" onAction="OnClickSettingsButton" /> 
      <button id="loginButton" label="Login" onAction="OnClickLoginButton" /> 
      <separator  id="Separator1" />
      <button id="myButton" enabled ="false" label="My Button" imageMso="CreateReportFromWizard" size="large" onAction="OnClickMyButton" />
      <button id="myOtherButton" enabled ="false" label="My Other Button" imageMso="DataRefreshAll" size="large" onAction="OnClickMyOtherButton" />
    </group>
  </tab>
</tabs>
</ribbon>
</customUI>


Thanks!!

New Post: Saving docx as txt

$
0
0
Hi,
I'm using NetOffice (1.6.0) for converting docx files to text:
var document = wordApplication.Documents.Open(fileName);
//
document.SaveAs(newFileName, NetOffice.WordApi.Enums.WdSaveFormat.wdFormatUnicodeText);
However, with non-ascii characters (lower german quotes, french chars) it's never the same like saving as *.txt from word itself.
Umlauts usually work, but the resulting file always appears to be ANSI, regardless of the chosen WdSaveFormat.

Anything I might have missed?
Thanks

New Post: Steps to create COMAddIn using NetOffice

$
0
0
Going through a number of samples in NetOffice but not able to recollect steps to create a Excel AddIn ( worksheet host a winform container and in turn it will host WPF chart using element host), able to do using VSTO but in NetOffice not able to followup.
In VSTO when you create excel AddIn then it insterst Excel sheet also and some generated code.
In Netoffice I need to refer NetOffice and NetOffice.ExcelAPI but how to to bring basic code.
Any suggestion is welcome.

New Comment on "ProjectWizardScreenshots_English"

$
0
0
I have installed NetOffice 1.6.0 but in project templates it is not showing NetOffice...is there anything I need to configure before it shows in Visual studio

New Post: XML enabled tag in Excel

$
0
0
Figured it out..

In XML:
You don't use the enabled= tag, you use the callback tag getEnabled=

<button id="myButton" label="My Button" imageMso="CreateReportFromWizard" size="large" onAction="OnClickMyButton" getEnabled="getMyButtonEnabled" />

In C#:
    // our ribbon instance to manipulate ui at runtime 
    private Office.IRibbonUI RibbonUI { get; set; }

     // defined in RibbonUI.xml to get a instance for ouer ribbon ui.
    public void OnLoadRibbonUI(Office.IRibbonUI ribbonUI)
    {
        RibbonUI = ribbonUI;
    }

    // defined in RibbonUI.xml to get MyButton state, and to set via return value
    public bool getReportsEnabled(Office.IRibbonControl control)
    {
        RibbonUI.InvalidateControl(control.Id);     //Must call InvalidateControl method on the button to force a refresh of it's state, set below

        return false;                // RETURN false TO DISABLE, RETURN true TO ENABLE.
    }

Since everything is in callbacks, you initially grab the RibbonUI for later use.
Then you use the getEnabled tag to define the callback routine onload and when updated later. By passing true or false at callback time it sets the control enabled or disabled accordingly.
Last you call InvalidateControl on the button you just fiddled with, to refresh the UI state.

Still perfecting my code, but hope this thread helps other NOOBS like me getting buttons to work.

Enjoy!

Created Unassigned: When to release event's COMObject? [21067]

$
0
0
When to release the newContentControl, DO I NEED to release it by myself, or NetOffice release it?

In the DocumentEvents2.cs
public void ContentControlOnExit([In, MarshalAs(UnmanagedType.IDispatch)] object contentControl, [In] [Out] ref object cancel)
{
Delegate[] recipients = _eventBinding.GetEventRecipients("ContentControlOnExit");
if( (true == _eventClass.IsCurrentlyDisposing) || (recipients.Length == 0) )
{
Invoker.ReleaseParamsArray(contentControl, cancel);
return;
}

NetOffice.WordApi.ContentControl newContentControl = NetOffice.Factory.CreateObjectFromComProxy(_eventClass, contentControl) as NetOffice.WordApi.ContentControl;
object[] paramsArray = new object[2];
paramsArray[0] = newContentControl;
paramsArray.SetValue(cancel, 1);
_eventBinding.RaiseCustomEvent("ContentControlOnExit", ref paramsArray);

cancel = (bool)paramsArray[1];
}
Viewing all 1741 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>