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

New Comment on "Word_Example05"

$
0
0
到 Visual Basic Project 的程序访问不被信任 === Programmatic Access To Visual Basic Project Is Not Trusted

New Comment on "Word_Example05"

$
0
0
I run the code above in a NetOffice AddIn.

New Comment on "Word_Example05"

$
0
0
[HKEY_CURRENT_USER\Software\Microsoft\Office\12.0\Word\Security] "AccessVBOM"=dword:00000001

New Post: Outlook IRibbonControl context - unable to cast to Inspector

$
0
0
Hi all!
I just started to play with NetOffice and generally it looks excellent!
However I have bumped into a problem on my first project.
I have created a ribbon button in Outlook and want to manipulate the Mailitem object when the button is pressed. The event is working well and I get the IRibbonControl object in my function.
However, I am unable to cast the control.Context property.
 public void btnSaveSend_Click(NetOffice.OfficeApi.IRibbonControl control)
  {
        var item = control.Context as NetOffice.OutlookApi.Inspector;
        var mailItem = item.CurrentItem as NetOffice.OutlookApi.MailItem;
        if (mailItem != null) MessageBox.Show(mailItem.Subject);
  }
The above method only returns item = null. If I try this:
 var item = (NetOffice.OutlookApi.Inspector)control.Context;
I get an error message:
_Unable to cast COM object of type 'System._ComObject' to class type 'NetOffice.OutlookApi.Inspector'. Instances of types that represent COM components cannot be cast to types that do not represent COM components; however they can be cast to interfaces as long as the underlying COM component supports QueryInterface calls for the IID of the interface.
_
When debugging the add-in I can see that there is actually a MailItem object inside control.Context.CurrentItem, so this is all down to casting.

I have seen several code examples where this is supposed to work, but for me it doesn't.


Any help guiding me in the right direction is greatly appreciated!

Ezpl

New Post: VSTO to NetOffice

$
0
0
Similar to the question above I used to use the line below in a static function to return a reference to the com addin:

return Globals.ThisAddin;


Can you please tell me how I can get a reference to the current addin object.

PS only been using this one day and it looks like a great project, thanks.

AT

New Post: Outlook IRibbonControl context - unable to cast to Inspector

$
0
0
IRibbonControl is an earlybind interface in NetOffice. (necessary because the office application want this)
use:
Outlook.Inspector item = new Outlook.Inspector(null, control.Context);
// stuff
item.Dispose();

*Sebastian

New Post: VSTO to NetOffice

$
0
0
NO spend a static helper module for the office application but not for the adinn instance currently (except for the NO tools namespace with more options)
but its easy to implement i find:
// example
class MyAddin
{
MyAddn()
{
   _singleton = this;
}
internal static Addin Singleton { get{ return _singleton;} } 
private static Addin _singleton;
}

// usage
return MyAddin.Singleton;

*Sebastian

New Post: VSTO to NetOffice

$
0
0
Wow that was a quick answer but not quite what I was looking for, the static function is in another class eg:
class AnotherClass()
{
   public static Addin GetAddin()
   {
      return ????
   }
}
The other class is a class I use for all my outlook projects and is a list of static helper functions, but unless they can reference the current addin they can't do much.

If the functions where not static I would do below but constructor is not used with static calls.
class AnotherClass()
{
   public Addin _ParentAddin;

   AnotherClass(Addin FromParent)
   {
      _ParentAddin = FromParent;
   }
   public static Addin GetAddin()
   {
      return _ParentAddin;
   }
}
Any Ideas?

Thanks again for your quick response.

Andrew

New Post: VSTO to NetOffice

$
0
0
Yep that works thank you so much :)

New Post: Erstellung Button in CommandBar nur bei Mail

$
0
0
A96E22AE-0DB8-4B63-8D92-6D8B8397F5E6

Betreff: Erstellung Button in CommandBar nur bei Mail

Hallo,
ich versuche seit einiger Zeit einen Button in die Standard-CommandBars zu integrieren, aber nur, wenn ein neues Mailfenster bzw. eine vorhandene Mail geöffnet wird, also nicht beim Öffnen einer Notiz oder eines Kallendereintrages.

Hier mal mein bisheriger Stand der Dinge:

Als erstes klinke ich mich in das Event ein, wenn ein neues Fenster geöffnet wird:
void IDTExtensibility2.OnConnection(object application, ext_ConnectMode connectMode, object addInInst, ref Array custom) {
   _outlookApplication = new Application(null, application);
   _outlookInspectors = _outlookApplication.Inspectors as Inspectors;
   
   if (_outlookInspectors != null) {
     _outlookInspectors.NewInspectorEvent += OutlookInspectorsNewInspectorEvent;
   }
}
Wenn dann ein Fenster geöffnet wird, schaue ich nach, ob es ein Mailitem ist. Wenn ja, dann füge einen Button zur standardBar hinzu
void OutlookInspectorsNewInspectorEvent(_Inspector inspector) {
  try {
    var citem = inspector.CurrentItem;
    if (citem is MailItem) {
      _standardBar = inspector.CommandBars["Standard"];

      _mBttn = (CommandBarButton)_standardBar.Controls.Add(MsoControlType.msoControlButton, 1, null, 3, true);
      _mBttn.Style = MsoButtonStyle.msoButtonIconAndCaption;
      _mBttn.FaceId = 225;  // Schloss (Icon)

      _mBttn.Caption = "Test";
      _mBttn.Tag = "MBUTTON";
      _mBttn.ClickEvent += MCmdBarBttnClickEvent;
    }
  }
}
Und zum Schluß noch der Button Event:
void MCmdBarBttnClickEvent(CommandBarButton ctrl, ref bool cancelDefault) {
  ...
  ctrl.Dispose();
}
Allerdings habe ich hier das Problem, dass sich mein ProxyCount immer weiter erhöht und ich nicht weiss,
ob bei einem Count von mehreren Hundert bis Tausend nach einem Arbeitstag, dies negative Auswirkungen auf die Performance haben könnte.

Wie sieht hier ein sauberes Vorgehen aus, um die Proxys so gering wie möglich zu halten ohne z.B. das Event für den dynamisch erstellten Button
in der Standardbar zu verlieren? Was ja z.B passieren würde, wenn ich am Ende von OutlookInspectorsNewInspectorEvent ein _standardBar.Dispose(); ausführen würde.

Oder gibt es eine ganz andere Vorgehensweise, wie ich einen Button in die StandardBar bekomme, eventuell mit "ein- und ausblenden"?

Danke und viele Grüße, Daniel

New Post: Erstellung Button in CommandBar nur bei Mail

$
0
0
Nach meiner Erfahrung ist alles <1000 Proxies okay (meine Faustregel) Allerdings hängt es auch davon ab was für ein Objekt hinter Proxy steht. Zur Erinnerung: Der Proxy ist nur ein Stellvertreter in der eigenen Anwendung für eine Instanz in der Office Anwendung. Je nachdem wieviel Speicher dieses tatsächliche Objekt belegt, steigt dadurch der Speicherverbrauch der Office Anwendung und irgendwann wird diese dann behäbig.

Zu deiner Frage:
NetOffice bietet für solche Fälle eine Überladung der Dispose und DisposeChildInstance Methoden an:
void Dispose(bool disposeEventLListener);

Du kannst also am Ende des Inspector Events inspector.Dispose(false); aufrufen um möglichst effizizient vorzugehen.


*Sebastian

New Post: Can't delete file after renaming due to Word file handle still present

$
0
0
Hi,

Any updates about this issue?

Best regards

Created Unassigned: Compile error in Tutorial 10 of v1.6 [20151]

$
0
0
I tried to compile the C# Tutorials.sln in NetOffice1.6\NET4.5\Tutorials\C# in VS2012Premium. The output was an error in Tutorials\Tutorials\Tutorial10.cs on line 39 and line 48. EnableMessageFilter is not a member of NetOffice.Settings. I comment out line 39 and revise line 40 so that it does not refer to bool messageFilter, and the solution compiles.

The same compilation error occurs in the .NET4.0 version of the tutorials.

New Post: COM Add-In "Not Loaded. Runtime error..."

$
0
0
Hi

I want to test my office add-in on my test machine. I registered it with regasm.exe name.dll /codebase

The plug-in is available in office, but I can't activate it. It tells: "Not loaded. A runtime error occurred during the loading of the COM Add-In"

I checked following:
  • LoadBehavior = 3
  • .Net 4 Client Profil and .Net 4.5 is installed
  • after "OnConnection" in my add-in I added an MessageBox but this do not appear. So plugin do not throw an exception.
Do I Need any more pre-requisites. Or can I get an log file what is going wrong while loading. Or other possible solutions?

New Post: COM Add-In "Not Loaded. Runtime error..."

$
0
0
mh totaly crazy. After complete removal (+ registry) and new installation it's running now.

New Post: Problem get outlook instance from ROT

$
0
0
Hi, do u get more informations? I 've tried a lot but the problem is still not solved!?

New Post: PowerPoint hide window

$
0
0
Hi

I want to modify an PowerPoint file in background.
PowerPoint.Application powerPointApplication = new PowerPoint.Application();
 powerPointApplication.DisplayAlerts = PpAlertLevel.ppAlertsNone;
            
            if (Utils.IsFileLocked(filePath)) {
                Utils.MessageBoxError("File (" + filePath + ") is open by a other process or can't write on it.", "POWERPOINT");
                return;
            }

PowerPoint.Presentation presentation = powerPointApplication.Presentations.Open(filePath);
But the PowerPoint application open, shows the presentation and close automatically.

If I activate
powerPointApplication.Visible = MsoTriState.msoFalse;  
I get follwoing error "Application.Visible : Invalid request. Hiding the application window is not allowed".

How is it possible to hide the window or don't popup the window!?

Reviewed: NetOffice 1.6.0 (Sep 11, 2013)

$
0
0
Rated 5 Stars (out of 5) - It's an excellent toolkit. It's very simple to create an Office Add-in and the support is very good. NICE WORK!!!!!

Commented Issue: Cannot call VBA methods with parameters [18896]

$
0
0
See my description (and solution) in this post
http://netoffice.codeplex.com/discussions/402559
Comments: ** Comment from web user: buehlert **

Hi Sebastian

Thanks a lot for a fantastic release 1.6.0!
Unfortunately the macro related issue I recognized has not been fixed yet.
Is there any chance of a working update?

Thanks and best regards,
Thomas

Commented Issue: Cannot call VBA methods with parameters [18896]

$
0
0
See my description (and solution) in this post
http://netoffice.codeplex.com/discussions/402559
Comments: ** Comment from web user: buehlert **

Here is some code to test this easily:

Create test.ppam with following subs/functions:
```
Public Sub TestAddin()
MsgBox ("Hello")
End Sub

Public Function TestAddin2() As String
TestAddin2 = "Hello "
End Function

Public Function TestAddin3(name As String) As String
TestAddin3 = "Hello " & name
End Function
```

Now, create a C# Test method like:
```
var powerApplication = new Application();
powerApplication.Visible = MsoTriState.msoTrue;
var addin = powerApplication.AddIns.Add("D:\test\test.ppam");
addin.Loaded = MsoTriState.msoTrue;

//1. Macro, no parameters, no return value
powerApplication.Run(addin.Name + "!TestAddin");

//2. Macro, no parameters, with return value
var res = powerApplication.Run(addin.Name + "!TestAddin2");
Debug.WriteLine(res.ToString());

//2. Macro, with parameters, with return value
var res2 = powerApplication.Run(addin.Name + "!TestAddin3", new Object[] { "test" });
Debug.WriteLine(res2.ToString());

powerApplication.Quit();
powerApplication.Dispose();
```

TestAddin -> works, message box will be displayed
TestAddin2 -> works, "Hello" is returned
TestAddin3 -> crashes -> it says "Application.Run : Invalid request. Sub or function not defined"

Viewing all 1741 articles
Browse latest View live




Latest Images