Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Visual Studio.NET / VS Tools for Office / January 2007

Tip: Looking for answers? Try searching our database.

VSTO 2005 SE: Problems accessing Globals object (or Session)...

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Pablo Alvarez - 09 Jan 2007 16:19 GMT
Hi all!

  I'm facing once again a new problem with my VSTO development :( I need to
access the Application.Session object from a window, and I'm unable to,
because my Globals.<nameofmyaddin> is refusing to return anything other than
null :( In the main addIn class, this very same line of code would work, but
here it does not. The line is:

Outlook.MAPIFolder root =
Utility.Folder.GetRootFolder(Globals.GRAAddIn.Application.Session);

  This very same line did work in MyAddin.cs class, but does not work from
a Windows Form class.. any tip? I am really in an urge :(

Thanks to all!
Pablo
Torben Laursen - 10 Jan 2007 09:15 GMT
I don't know if this is the best way but this code can be used for excel
using MSExcel = Microsoft.Office.Interop.Excel;

private MSExcel.Worksheet Sheet;

private MSExcel.Application App;

private void Prepare()

{

App = (MSExcel.Application)Marshal.GetActiveObject("Excel.Application");

Sheet = (MSExcel.Worksheet)App.ActiveWorkbook.ActiveSheet;

}

Torben

> Hi all!
>
[quoted text clipped - 12 lines]
> Thanks to all!
> Pablo
Pablo Alvarez - 10 Jan 2007 15:23 GMT
Thanks for the replay Torben.. I'll look at this approach, at this Marshal
thing :)

Cheers!
Pablo

>I don't know if this is the best way but this code can be used for excel
> using MSExcel = Microsoft.Office.Interop.Excel;
[quoted text clipped - 31 lines]
>> Thanks to all!
>> Pablo
Ken Slovak - [MVP - Outlook] - 10 Jan 2007 14:23 GMT
You could set up a public object or method in the form and pass the Session
object (NameSpace) to it when you create the form.

Signature

Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm

> Hi all!
>
[quoted text clipped - 12 lines]
> Thanks to all!
> Pablo
Pablo Alvarez - 10 Jan 2007 15:21 GMT
Yep, I am able to do that as a walkaround, but I'd love to understand what
is happening, why am I abnle to access from other places and not from a
form. I have little COM knowledge, but I thought it could be because of
accessing the COM object from a form. Makes sense?

Thanks a lot!
Pablo

> You could set up a public object or method in the form and pass the
> Session object (NameSpace) to it when you create the form.
[quoted text clipped - 15 lines]
>> Thanks to all!
>> Pablo
Ken Slovak - [MVP - Outlook] - 10 Jan 2007 20:14 GMT
I'm not sure, I don't know enough of the plumbing under the hood in VSTO or
the Interop to really be sure. In VB.NET you can set up global Application
and NameSpace objects and reference them from anywhere in your code,
including form code but of course C# has different scope rules and nothing
like true globals as VB.NET does.

Signature

Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm

> Yep, I am able to do that as a walkaround, but I'd love to understand what
> is happening, why am I abnle to access from other places and not from a
[quoted text clipped - 3 lines]
> Thanks a lot!
> Pablo

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.