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

  • Question

  • 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”);

    Wednesday, February 26, 2014 9:52 PM

Answers

All replies

  • Hi,

    You should be able to say this:


    $wdFormatFilteredHTML = 10
    $saveFormat = $wdFormatFilteredHTML

    Bill

    Wednesday, February 26, 2014 10:06 PM
    Moderator
  • 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 ...

      

    Wednesday, February 26, 2014 10:42 PM
  • Add-Type -assembly Microsoft.Office.Interop.Word
    [Microsoft.Office.Interop.Word.WdSaveFormat]::wdFormatFilteredHTML


    ¯\_(ツ)_/¯



    • Edited by jrv Thursday, February 27, 2014 8:45 AM
    Wednesday, February 26, 2014 10:43 PM
  • + Add-Type <<<<  -assembly Microsoft.Office.Interop.Word.WdSaveFormat
        + CategoryInfo          : ObjectNotFound: (Microsoft.Offic...rd.WdSaveFormat:String) [Add-Type], Exception
        + FullyQualifiedErrorId : ASSEMBLY_NOT_FOUND,Microsoft.PowerShell.Commands.AddTypeCommand
    Thursday, February 27, 2014 8:09 AM
  • + Add-Type <<<<  -assembly Microsoft.Office.Interop.Word.WdSaveFormat
        + CategoryInfo          : ObjectNotFound: (Microsoft.Offic...rd.WdSaveFormat:String) [Add-Type], Exception
        + FullyQualifiedErrorId : ASSEMBLY_NOT_FOUND,Microsoft.PowerShell.Commands.AddTypeCommand

    Sorry but I fixed that in an edit but, as is happening frequently this week.  The edit was lost.

    This is what it should show.

    Add-Type -assembly Microsoft.Office.Interop.Word

    If that fails then you do not have the assemblies installed.  THey are not installed by default on versions earlier than 2010.


    ¯\_(ツ)_/¯

    Thursday, February 27, 2014 8:45 AM
  • I just tested on Windows 7 with Office 2007 full install and it works as expected.


    ¯\_(ツ)_/¯

    Thursday, February 27, 2014 8:56 AM
  • thank you for your reply. 

    In this way assebly has been loaded.

    Now, the problem is that Office 2010 has need [ref] : 
    $MSWord.ActiveDocument.saveas([ref]$path, [ref]$saveFormat)

    while office 2010 does not want it:
    $MSWord.ActiveDocument.saveas($path, $saveFormat)


    Thursday, February 27, 2014 9:17 AM
  • Sorry.  I can't help with that.  Post that issue in Office developer forum.


    ¯\_(ツ)_/¯

    Thursday, February 27, 2014 9:30 AM