PowerShell, Office 2007: [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.Office.Interop.Wor‌​d")

Hi All,
I have problem to convert word document in to html (Office 2007)
Interop Assembly appear to work but powershell returns:
Unable to
find type [Microsoft.Office.Interop.Word.WdSaveFormat]:  
I'using :
$saveFormat = [Enum]::Parse([Microsoft.Office.Interop.Word.WdSaveFormat], “wdFormatFilteredHTML”);

Hi Bill,
Thank for your reply.
I found this usefull script: http://gallery.technet.microsoft.com/office/6f7eee4b-1f42-499e-ae59-1aceb26100de
On W7 + Office 2010 Works fine with no errors
ONLY On W7 + Office 2007  returns "Unable to
find type [Microsoft.Office.Interop.Word.WdSaveFormat]:"
Interop Ass. same to work, only "save format" have potential strange issue.
I don't understand why with Office 2007 only ...

Similar Messages

  • Why use System Reflection Assembly

    I am just starting to learn forms in Powershell and noticed that in almost every example the follow code is put at the top of the example:
    [void] [System.Reflection.Assembly]::LoadWithPartialName("System.Drawing")
    [void] [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")
    If I comment it out, my script still appears to work. Can someone enlighten me on why this is done or what advantage there is to doing this?
    I understand that these are .Net name spaces, but I don't see any difference in the behavior of my forms when I add or remove these lines. Is this something related to older versions of Powershell? Currently running on version 3.0...

    Once you've loaded these assemblies, they stay loaded for your entire PowerShell session.  If you commented out those lines and tried to run the script in a new ISE or PowerShell console, it should fail (unless you have something in your profile or
    an imported module which is loading them anyway.)
    Personally, I prefer to use the commands this way, but the end result is the same:
    Add-Type -AssemblyName System.Drawing
    Add-Type -AssemblyName System.Windows.Forms

  • How to add text vertically into a Word margin with C# (using namespace: Microsoft.Office.Interop.Word)

    I need to add text vertically in a word document outside the margins.  How can I do this with Microsoft.Office.Interop.Word and C#?
    Leonard Swarczinski Software Developer Postal Center International

    Hi Leonard,
    According to your description, do you want to add text vertically into Page Header/Footer? I wrote a sample  for you.
    using Microsoft.Office.Core;
    using Microsoft.Office.Interop.Word;
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    namespace AddTextToWord
    class Program
    static void Main(string[] args)
    CreateNewDocument();
    Console.ReadLine();
    private static void CreateNewDocument()
    Object oMissing = System.Reflection.Missing.Value;
    Microsoft.Office.Interop.Word.Application oWord;
    Microsoft.Office.Interop.Word.Document oDoc;
    oWord = new Microsoft.Office.Interop.Word.Application();
    oWord.Visible = true;
    oDoc = oWord.Documents.Add(ref oMissing, ref oMissing, ref oMissing, ref oMissing);
    String HeaderText = "Hello everyone!";
    WdParagraphAlignment wdAlign = WdParagraphAlignment.wdAlignParagraphCenter;
    AddHeader1(oWord, HeaderText, wdAlign);
    private static void AddHeader1(Application WordApp, string HeaderText, WdParagraphAlignment wdAlign)
    Object oMissing = System.Reflection.Missing.Value;
    WordApp.ActiveWindow.View.Type = WdViewType.wdOutlineView;
    WordApp.ActiveWindow.View.SeekView = WdSeekView.wdSeekPrimaryHeader;
    Microsoft.Office.Interop.Word.Shape textBox = WordApp.ActiveDocument.Shapes.AddTextbox(MsoTextOrientation.msoTextOrientationVertical, 150, 10, 40, 40);
    textBox.TextFrame.TextRange.Text = HeaderText;
    WordApp.ActiveWindow.View.SeekView = WdSeekView.wdSeekMainDocument;
    If I misunderstood or anything wrong, please let me know and you can get more information from below articles.
    Office development in Visual Studio
    http://msdn.microsoft.com/en-us/office/hh133430.aspx
    Abhout: AddTextbox Method
    http://msdn.microsoft.com/en-us/library/office/aa171543(v=office.11).aspx
    How to: Programmatically Insert Text into Word Documents
    http://msdn.microsoft.com/en-us/library/vstudio/6b9478cs.aspx

  • File or assembly name microsoft.office.interop.excel or one of its dependen

    Hi Team,
    When i click on the manage dimension members for a dimension i am getting the following error,
    "file or assembly name microsoft.office.interop.excel or one of its dependencies was not found"
    How i can resolve this?
    Regards,
    Raj,

    Hi Raj,
    What did you do exactly to resolve this issue? Are you no longer using Office 2007 or did you reinstall it? What are the specific steps you took?
    I recently upgraded from SP02 to SP07 and now have the same problem. It was working fine prior to the upgrade.
    Thanks,
    Rob
    Edited by: Rob Delong on Feb 19, 2010 3:42 AM

  • Datamining PST Files using Microsoft.Office.Interop.Outlook

    I was wondering how to datamine a pst file beyond it's primary folders to see if an empty folder has content in a subfolder and add it to an existing psobject?
    Cheers,
    B.
    $results = New-Object System.Collections.ArrayList # Empty Array
    $null = Add-type -assembly Microsoft.Office.Interop.Outlook
    $outlook = new-object -comobject outlook.application
    $namespace = $outlook.GetNameSpace('MAPI')
    $pstpath = "d:\sample.pst"
    $namespace.AddStore($pstpath)
    $PST = $namespace.Stores | ? {$_.FilePath -eq $pstpath}
    $PSTRoot = $PST.GetRootFolder()
    $PSTName = $PST.Displayname
    Foreach ($folders in $PSTRoot.Folders) {
    $x = $folders.Name
    $y = $folders.FolderPath
    $z = $folders.Items.Count
    $Object = New-Object PSObject
    $Object | Add-Member -Name 'Name' -MemberType Noteproperty -Value $x
    $Object | Add-Member -Name 'Path' -MemberType Noteproperty -Value $y
    $Object | Add-Member -Name 'Items' -MemberType Noteproperty -Value $z
    $results += $object
    $results | Format-Table 'Name','Path','Items' -Wrap -AutoSize | Out-Default
    $results = $NULL

    Hi B,
    If you want to test the access of the .pst file, please refer to the function below:
    function Test-PSTFile {
    param(
    [Parameter(Position=1, ValueFromPipeline=$true, Mandatory=$true)]
    $FilePath,
    [Parameter(Position=2, Mandatory=$false)]
    $ErrorLog
    process {
    #Create an instance of Outlook
    $null = Add-type -assembly Microsoft.Office.Interop.Outlook
    $olFolders = 'Microsoft.Office.Interop.Outlook.olDefaultFolders' -as [type]
    $outlook = new-object -comobject outlook.application
    #Open the MAPI profile
    $namespace = $outlook.GetNameSpace('MAPI')
    try {
    #Try to add the PST file to the profile
    $namespace.AddStore($FilePath)
    #Try to read the root folder name
    $PST = $namespace.Stores | ? {$_.FilePath -eq $FilePath}
    $PSTRoot = $PST.GetRootFolder()
    if($PSTRoot) {
    New-Object PSObject -Property @{
    FileName = $FilePath
    Valid = $True
    #Disconnect the PST
    $PSTFolder = $namespace.Folders.Item($PSTRoot.Name)
    $namespace.GetType().InvokeMember('RemoveStore',[System.Reflection.BindingFlags]::InvokeMethod,$null,$namespace,($PSTFolder))
    catch {
    #If logging is on, save the error to the log
    if($ErrorLog) {
    Add-Content -Path $ErrorLog -Value ("Ran into a problem with {0} at {1}. The error was {2}" -f $FilePath, (Get-Date).ToString(),$_.Exception.Message)
    #Output a failure record
    New-Object PSObject -Property @{
    FileName = $FilePath
    Valid = $False
    Refer to:
    How to Test Outlook (PST) Personal Folder File Access with PowerShell
    If there is anything else regarding this issue, please feel free to post back.
    Best Regards,
    Anna Wang

  • Microsoft.Office.Interop.Word error on Windows Server 2008 R2

    Hi,
    I have Microsoft Office 2003 installed on Windows Server 2008 R2. I get a "There is insufficient memory. Save the document now." error while adding a document to the Microsoft.Office.Interop.Word.Document class as in the code below. I can see the Memory
    consumption shoots up as soon as the following lines of code is executed. Surprisingly, this same piece of code works fine on Windows Server 2008.
    Object missing = System.Reflection.Missing.Value;
    Object oFalse = false;
    Microsoft.Office.Interop.Word.Application oWord = new Application();
    Microsoft.Office.Interop.Word.Document oWordDoc = new Microsoft.Office.Interop.Word.Document();
    oWordDoc = oWord.Documents.Add(ref missing, ref missing, ref missing, ref missing); //The code fails here
    oWordDoc.Close(ref oFalse, ref missing, ref missing);
    oWord.Quit(ref missing, ref missing, ref missing);
    Can someone help on this?
    Thanks,
    Tarun

    Hi,
    I suggest discussing this issue in Word or IIS forum.
    Word forum:
    http://social.technet.microsoft.com/Forums/en-us/word/threads
    IIS forum:
    http://forums.iis.net/
    Tim Quan

  • BPC 7.5 NW Processing Dimensions Microsoft.Office.Interop.Excell issue

    Hi
    I've tried all the downloads (service Packs, Interop Files etc) mentioned in all websites and posts to try and fix following error:
    "Unable to cast COM object of type 'Microsoft.Office.Interop.Excel.ApplicationClass' to interface type 'Microsoft.Office.Interop.Excel_Application'. This Opperation failed because the Query Interface call on the COM component for the interface with ID '{000208D5-0000-0000-C000-0000000000046}' failed due to the following error: Library not registered.
    I get this only when I try to Process a dimension
    Please can anyone tell me how to fix this?
    We have installed BPC 7.5 NW
    I had Office 2010 and could process but my input schedules didn't work 100% on Office 2007 so I had to go back to 2007. And now I can't process in the Admin Client. I've uninstalled and reinstalled Office and BPC 7.5 NW SP07 a few times to try and solve this but no luck.
    Thanks
    Johan Fourie

    Hi,
    If you are using excel 2007, you need to install the redistributable primary interop assembly from the below link:
    https://websmp230.sap-ag.de/sap%28bD1lbiZjPTAwMQ==%29/bc/bsp/sno/ui_entry/entry.htm?param=69765F6D6F64653D3030312669765F7361706E6F7465735F6E756D6265723D3134363332383926
    Hope this helps.

  • Whats the main difference between Add-Type and [Reflection.Assembly]::LoadFrom($DLL.FullName) for example

    Hello
    I have a query please, if someone can help answer it
    I am just not clear on when to use which method and if they need to be used together some of the time or all of the time.
    Is it true to say the answer to the above is you use Add-Type when the DLL containing the type has already been loaded into memory but not yet scope of the script (e.g. like the 'using' statement
    in C#)
    if the DLL or its manifest is not in memory then you need to firs to load into memory via
     [Reflection.Assembly]::LoadFrom($DLL.FullName) 
    for example?
    But if that is the case do you not then need to use Add-Type once LoadFrom has loaded into memory to get the members of the type?
    Thank you
    AAnotherUser__
    AAnotherUser__

    This is a recent thread with some discussion of the differences - between using and Load/Add-Type.
    http://social.technet.microsoft.com/Forums/windowsserver/en-US/9fe4c708-c98e-432e-a4e1-4a8e80250c18/how-do-i-loadreference-assemblies-in-powershell?forum=ITCG
     Load and Add-Type are basically the same thing, and once the
    assembly's been loaded in memory it's available, so there's no using equivalent.
    I hope this post has helped!

  • Error: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. --- System.NullReferenceException: Object reference not set to an instance of an object

    Hi,
    (1) I am trying to get the data from a database table and import into a text file.
    (2) If the record set have the data then it runs ok
    (3) when the record set not having any data it is giving the below error
    Error: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.NullReferenceException: Object reference not set to an instance of an object
    Could you please let me know why this is happening?
    Any help would be appriciated
    Thanks,
    SIV

    You might ask them over here.
    http://social.msdn.microsoft.com/Forums/vstudio/en-US/home?forum=vbgeneral%2Ccsharpgeneral%2Cvcgeneral&filter=alltypes&sort=lastpostdesc
    Regards, Dave Patrick ....
    Microsoft Certified Professional
    Microsoft MVP [Windows]
    Disclaimer: This posting is provided "AS IS" with no warranties or guarantees , and confers no rights.

  • I cannot download itunes on my pc.  I get the message "An error occurred during the installation of assembly. "microsoft.VC80.CRT.type=8 0.50727.4053". publicKeyToken="1fc8b3b9a1e18e3b". processor rArchitecture=amd64".

    i cannot download itunes on my pc.  I get the message "An error occurred during the installation of assembly. "microsoft.VC80.CRT.type=8 0.50727.4053". publicKeyToken="1fc8b3b9a1e18e3b". processor rArchitecture=amd64".
    Please help. Have just bought a new ipod and cannot use it !!! Thank you.

    Hi Gurmo,
    HRESULT: 0x80073712 means ERROR_SXS_COMPONENT_STORE_CORRUPT, and it is one of the error codes listed at this
    KB article.
    I suggest you run the System Update Readiness tool and check if the error still persists.
    There is a similar thread for your reference.
    https://social.technet.microsoft.com/Forums/en-US/0b3d0479-b9c0-4551-a623-1519ce7584af/error-when-installing-sql-server-2008-r2-rtm-on-windows-server-2008-r2-foundation?forum=winservergen
    Thanks,
    Lydia Zhang
    If you have any feedback on our support, please click
    here.
    Lydia Zhang
    TechNet Community Support

  • Microsoft.Office.Interop.Excel

    Which forum should I use to ask questions about using C# & Microsoft.Office.Interop.Excel for spreadsheets?
    Rob E.

    Hello,
    I'd ask in the
    Excel for Developers forum.
    Karl
    When you see answers and helpful posts, please click Vote As Helpful, Propose As Answer, and/or Mark As Answer.
    My Blog: Unlock PowerShell
    My Book: Windows PowerShell 2.0 Bible
    My E-mail: -join ('6F6C646B61726C40686F746D61696C2E636F6D'-split'(?<=\G.{2})'|%{if($_){[char][int]"0x$_"}})

  • Error 1310. Error writing to file: Policy.12.0.Microsoft.Office.Interop.Access.dll AHHHHHH!!!

    I'm trying to install Office 2010 Professional Plus on Windows 7 Ultimate
    I keep getting this error and I'm at witts end
    Error 1310. Error writing to file: Policy.12.0.Microsoft.Office.Interop.Access.dll.
    Verify that you have access to that directory
    I have completely uninstalled Office 2007, ran CCLeaner, Windows Install Cleanup, followed the idea's on the forums
    http://social.technet.microsoft.com/Forums/en-US/office2010/thread/4e8beb60-ac2b-4fc5-b510-628b65d7cc67
    WTH? I get the same error no matter what I do, Can anyone PLEASE help?

    Hi
    Thank you for using
    Microsoft Office for IT Professionals Forums.
    Follow these methods one by one test this issue:
    1.      
    Complete uninstall previous version of office: 
    http://support.microsoft.com/kb/290301
    2.      
    troubleshoot a problem by performing a clean boot in Windows 7
    http://support.microsoft.com/kb/929135
    3.      
    Test with a new user account
    Ÿ  
    Create a user account
    Ÿ  
    Fix a corrupted user profile
    Please take your time to try the suggestions and let me know the results at your earliest convenience. If anything is unclear or if there is anything I can do for
    you, please feel free to let me know.
    Best regards
    William Zhou
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

  • System.ServiceModel.Security.SecurityNegotiationException,Microsoft.Online.Administration.Automation.ConnectMsolService

    [2014/11/18 10:25:51.3] Microsoft.Online.Administration.Automation.MicrosoftOnlineException,Microsoft.Online.Administration.Automation.ConnectMsolService : Exception of type 'Microsoft.Online.Administration.Automation.MicrosoftOnlineException' was thrown.
    [2014/11/18 10:25:51.3] System.ServiceModel.Security.SecurityNegotiationException,Microsoft.Online.Administration.Automation.ConnectMsolService : Could not establish trust relationship for the SSL/TLS secure channel with authority 'provisioningapi.microsoftonline.com'.
    [2014/11/18 10:25:48.9] Import-Module msonline; Connect-MsolService;
    This is on a Windows Server 2012 box and has the latest sign in assistant and azure ad powershell module from http://msdn.microsoft.com/en-us/library/azure/jj151815.aspx#bkmk_installmodule
    Sometimes this happens, and yet sometimes it does not.  It's perplexing.

     https://provisioningapi.microsoftonline.com/
    gives
    me a 403: Forbidden, Access is denied
    the certificate chain appears valid when viewed through google chrome
    given, i fired up my app and it did not experience the error in question ( SecurityNegotiationException
    ) immediately after viewing the page in google chrome
    it's weird, almost as if the certificate is being jacked around and made invalid through a finicky means.
    Tracing route to prd-provisioning.msods.nsatc.net [157.55.130.77]
    over a maximum of 30 hops:
      1    <1 ms    <1 ms    <1 ms  192.168.1.1
      2     1 ms    <1 ms    <1 ms  192.168.0.1
      3   142 ms   144 ms   143 ms  fl-71-1-144-1.dhcp.embarqhsd.net [71.1.144.1]
      4    78 ms    72 ms    84 ms  fl-69-68-14-241.dyn.embarqhsd.net [69.68.14.241]
      5    91 ms    91 ms    91 ms  173-248-66-238.centurylink.net [173.248.66.238]
      6     *        *        *     Request timed out.
      7     *        *        *     Request timed out.
      8    65 ms    58 ms    64 ms  nap-edge-04.inet.qwest.net [67.14.29.166]
      9    78 ms    78 ms    79 ms  65.122.166.30
     10    67 ms    85 ms   108 ms  ae0-0.mia-96cbe-1b.ntwk.msn.net [204.152.140.53]
     11    82 ms    85 ms    92 ms  ae12-0.atb-96cbe-1b.ntwk.msn.net [207.46.47.178]
     12    56 ms   121 ms   105 ms  ae0-0.atb-96cbe-1a.ntwk.msn.net [191.234.81.166]
     13    60 ms   104 ms    78 ms  ae11-0.bl2-96c-1a.ntwk.msn.net [207.46.33.237]
     14    97 ms    90 ms    59 ms  ae5-0.bl2-96c-1b.ntwk.msn.net [191.234.80.61]
     15    60 ms    85 ms    67 ms  10.22.112.182
     16     *        *        *     Request timed out.
     17     *        *        *     Request timed out.
     18     *        *        *     Request timed out.
     19     *        *        *     Request timed out.
     20     *        *        *     Request timed out.
     21     *        *        *     Request timed out.
     22     *        *        *     Request timed out.
     23     *        *        *     Request timed out.
     24     *        *        *     Request timed out.
     25     *        *        *     Request timed out.
     26     *        *        *     Request timed out.
     27     *        *        *     Request timed out.
     28     *        *        *     Request timed out.
     29     *        *        *     Request timed out.
     30     *        *        *     Request timed out.
    Trace complete.

  • The Web Service plug-in failed in OrganizationId and Unhandled Exception: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation

    Hi All,We are receiving below errors in our production envrionment as The Web Service plug-in failed in OrganizationId: c28f361a-8111-e211-b7f2-68b599c03df8; SdkMessageProcessingStepId: 36ccbb1b-ea3e-db11-86a7-000a3a5473e8;
     1.EntityName: userquery; Stage: 30; MessageName: RetrieveMultiple;
    Exception: Unhandled Exception: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation
    Inner Exception: System.IndexOutOfRangeException: #TotalRecordCount
    <Data>Unhandled Exception: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
    Inner Exception: System.IndexOutOfRangeException: #TotalRecordCount
    2.EntityName: email; Stage: 30; MessageName: RetrieveMultiple
    Exception: Unhandled Exception: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation
    Inner Exception: System.NullReferenceException: Object reference not set to an instance of an object
    <Data>Unhandled Exception: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation
    Inner Exception: System.NullReferenceException: Object reference not set to an instance of an object.
    3.
    EntityName: plugintype; Stage: 30; MessageName: RetrieveMultiple;
    <Data>Unhandled Exception: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
    Inner Exception: System.InvalidOperationException: There is already an open DataReader associated with this Command which must be closed first.
    Exception: Unhandled Exception: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
    Inner Exception: System.InvalidOperationException: There is already an open DataReader associated with this Command which must be closed firstPlease give us idea on above issues.
    Natarajan.V

    Hi,
    What version of CRM you are using? Does this happen when you open the case record?
    We have faced the similar for Account record and was solved using below query. I am not sure about incident.
    Update ACC
    SET ACC.Merged = 0
    from AccountBase ACC
    WHERE ACC.merged is null
    Do you have case merge option enabled on incident entity? As per the MS it is enabled for CRM 2013 SP1 and CRM 2015.
    http://www.microsoft.com/en-us/dynamics/crm-customer-center/merge-similar-cases.aspx 
    Thanks!
    Kalim Khan

  • On cleanuing up COM object when using Microsoft.Office.Interop.Excel

    When using Microsoft.Office.Interop.Excel the COM objects that are created by the code must be released using System.Runtime.InteropServices.Marshal.ReleaseComObject().
    Most of the time it's pretty clear when a new COM object is created such as:
    Excel._Application excelApp = null;
    Excel._Workbook wb = null;
    Excel._Worksheet ws = null;
    Excel.Range newRange = null;
    try
    // four COM objects are created below
    excelApp = new Excel.Application();
    wb = excelApp.Workbooks.Add();
    ws = (Excel.Worksheet)wb.Worksheets.Add();
    newRange = (Excel.Range)ws.Range["A1","A30"];
    // do these line of cod create new COM object?
    newRange.Font.Bold = true;
    newRange.Borders.Color = borderColor;
    finally
    if (excelApp != null) Marshal.ReleaseComObject(excelApp)
    if (wb != null) Marshal.ReleaseComObject(wb)
    if (ws != null) Marshal.ReleaseComObject(ws)
    if (newRange != null) Marshal.ReleaseComObject(newRange)
    In the above code I create four COM objects in the first part that need to be released when I'm finished with them. But it's not clear if the other two lines of code create a new COM object or not.  If they do then my code needs to look more
    like this:
    Excel._Application excelApp = null;
    Excel._Workbook wb = null;
    Excel._Worksheet ws = null;
    Excel.Range newRange = null;
    Excel.Font fnt = null;
    Excel.Borders bds = null;
    try
    // four COM objects are created below
    excelApp = new Excel.Application();
    wb = excelApp.Workbooks.Add();
    ws = (Excel.Worksheet)wb.Worksheets.Add();
    newRange = (Excel.Range)ws.Range["A1","A30"];
    // do these line of cod create new COM object?
    fnt = newRange.Font
    fnt.Bold = true;
    bds = new newRange.Borders;
    bds.Color = borderColor;
    finally
    if (excelApp != null) Marshal.ReleaseComObject(excelApp)
    if (wb != null) Marshal.ReleaseComObject(wb)
    if (ws != null) Marshal.ReleaseComObject(ws)
    if (newRange != null) Marshal.ReleaseComObject(newRange)
    if (fnt != null) Marshal.ReleaseComObject(fnt)
    if (bds != null) Marshal.ReleaseComObject(bds)
    How can I tell if getting a property creates a new COM object or not?

    Thank you for your replay but I do understand that the font object is a COM object.  What I'm trying to figure out is if a NEW object is created each time I access the font member of a Range object and if I need to call
    Marshal.ReleaseComObject on the font object after using it.
    Most member object of an object are a single instance and each time you access the member you simply get the pointer to that instance. For example:
    using(DataTable dt = new DataTable("Some Table Name"))
    PropertyCollection ep1 = dt.ExtendedProperties;
    PropertyCollection ep2 = dt.ExtendedProperties;
    if (Object.ReferenceEquals(ep1,ep2)) Console.WriteLine("They are the same object");
    else Console.WriteLine("They are different objects");
    The output will be: They are the same object
    On the other hand this:
    Excel._Application excelApp = new Excel.Application();
    Excel._Workbook wb = excelApp.Workbooks.Add();
    Excel._Worksheet ws = (Excel.Worksheet)wb.Worksheets.Add();
    Excel.Range newRange = (Excel.Range)ws.Range["A1","A30"];
    // do these lines of code create new COM object?
    Excel.Font ef1 = newRange.Font;
    Excel.Font ef2 = newRange.Font;
    if (Object.ReferenceEquals(ef1,ef2)) Consloe.WriteLine("They are the same object");
    else Consloe.WriteLine("They are different objects");
    The output will be: They are different objects
    It looks like each time I access the font member I get a new object.  I suspect that is not the case and what I am getting is two pointers to the same object and the reference counter is incremented by one.
    So really the question is what happens to the font member object of the Range object when the range object is released.  I assume the font member will be released along with the Range object ever if the font object has a reference count greater then
    0.
    If I am correct in my assumption then I can access the font member object as much as I need to without worrying about releasing it.
    I have been reading a lot about working with COM and the need to use Marshal.ReleaseComObject and there does seem to be a lot of disagreement and even confusion on the
    mater about when and if COM objects need to be explicitly released.

Maybe you are looking for

  • SQL Authenticator Issue not able to see roles /groups in BPM Worklist

    Hi , I had configured the SQL Authenticator in Web logic using the SQL Authenticator default scripts and i have inserted few users. I am able to login to the Workspace using the users available in DB but i am not to able to see his group / role to wh

  • Converting lines to fills

    A client of mine has all these product logos that have a thick 10-point outline around the text. When I import these logos into Flash I always want to convert the outline to a fill, because otherwise when I use alpha to fade the logo in and out durin

  • Can't restore/update any iPhone!! Help!!

    Hello, I have tried trawling the threads for answer but so far no luck. I have got a Macbook Pro 13inch, an iPhone 4 and an iPhone 3GS. Whenever I try to update or restore the software on any of the phones, the progress bar on iTunes gets about 95% f

  • HT202213 ITunes and homesharing and apple tv on iMac G5

    followed all instructions and the appletv connects, says it is reading the library then fails.  also, there is no homesharing item in the left tree on itunes.  homesharing is on and logged in though.

  • Identifying when and where a class was built and its rev. number

    I have to create applications that go into environments that are regulated by folks like the FDA. This means that when the apps are deployed we want to have a script that demonstrates the correct components are installed in the right place. This requ