Windows Vista Forums

Can not open an existing Excel worksheet
  1. #1


    TPGBrennan Guest

    Can not open an existing Excel worksheet

    I have read through the previous posts on this forum for opening excel; I
    have searched TechNet and read the various articles; I have the MS Windows
    PowerShell Scripting Guide and nothing works.



    I am trying to open an existing Excel worksheet; the file exists and is
    accessible to me.

    This line of code returns the following error:
    PS C:\> $b = $xl.workbooks.open($file1)
    Exception calling "Open" with "1" argument(s): "Old format or invalid type
    library. (Exception from HRESULT: 0x80028018
    (TYPE_E_INVDATAREAD))"
    At line:1 char:24
    + $b = $xl.workbooks.open( <<<< $file1)

    This line of code, which looks remarkably similiar, returns a different error:
    $workbook=$objexcel.workbooks.open($file1)
    You cannot call a method on a null-valued expressio
    At C:\test4.ps1:4 char:35
    + $workbook=$objexcel.workbooks.open( <<<< $file1)

    Both were preceded by a definition of $file1 and the new-object
    excel.application command. Is it possible to open an Excel 2003 worksheet in
    Powershell 1?

      My System SpecsSystem Spec

  2. #2


    Marco Shaw [MVP] Guest

    Re: Can not open an existing Excel worksheet

    Can you provide more of your code? From start to error...

    Marco

    "TPGBrennan" <TPGBrennan@xxxxxx> wrote in message
    news:F54768B6-19F2-4EDC-AAB2-85E2103FDDDD@xxxxxx

    > I have read through the previous posts on this forum for opening excel; I
    > have searched TechNet and read the various articles; I have the MS Windows
    > PowerShell Scripting Guide and nothing works.
    >
    > I am trying to open an existing Excel worksheet; the file exists and is
    > accessible to me.
    >
    > This line of code returns the following error:
    > PS C:\> $b = $xl.workbooks.open($file1)
    > Exception calling "Open" with "1" argument(s): "Old format or invalid type
    > library. (Exception from HRESULT: 0x80028018
    > (TYPE_E_INVDATAREAD))"
    > At line:1 char:24
    > + $b = $xl.workbooks.open( <<<< $file1)
    >
    > This line of code, which looks remarkably similiar, returns a different
    > error:
    > $workbook=$objexcel.workbooks.open($file1)
    > You cannot call a method on a null-valued expressio
    > At C:\test4.ps1:4 char:35
    > + $workbook=$objexcel.workbooks.open( <<<< $file1)
    >
    > Both were preceded by a definition of $file1 and the new-object
    > excel.application command. Is it possible to open an Excel 2003 worksheet
    > in
    > Powershell 1?

      My System SpecsSystem Spec

  3. #3


    Vadims Podans [MVP] Guest

    Re: Can not open an existing Excel worksheet

    All Microsoft Office editions prior Office 2010 have a bug:
    http://support.microsoft.com/kb/320369/

    therefore you should change your locale to United States.
    --
    WBR, Vadims Podans
    MVP: PowerShell
    PowerShell blog - www.sysadmins.lv

    "TPGBrennan" <TPGBrennan@xxxxxx> rakstīja ziņojumā
    "news:F54768B6-19F2-4EDC-AAB2-85E2103FDDDD@xxxxxx"...

    > I have read through the previous posts on this forum for opening excel; I
    > have searched TechNet and read the various articles; I have the MS Windows
    > PowerShell Scripting Guide and nothing works.
    >
    > I am trying to open an existing Excel worksheet; the file exists and is
    > accessible to me.
    >
    > This line of code returns the following error:
    > PS C:\> $b = $xl.workbooks.open($file1)
    > Exception calling "Open" with "1" argument(s): "Old format or invalid type
    > library. (Exception from HRESULT: 0x80028018
    > (TYPE_E_INVDATAREAD))"
    > At line:1 char:24
    > + $b = $xl.workbooks.open( <<<< $file1)
    >
    > This line of code, which looks remarkably similiar, returns a different
    > error:
    > $workbook=$objexcel.workbooks.open($file1)
    > You cannot call a method on a null-valued expressio
    > At C:\test4.ps1:4 char:35
    > + $workbook=$objexcel.workbooks.open( <<<< $file1)
    >
    > Both were preceded by a definition of $file1 and the new-object
    > excel.application command. Is it possible to open an Excel 2003 worksheet
    > in
    > Powershell 1?

      My System SpecsSystem Spec

  4. #4


    Vadims Podans [MVP] Guest

    Re: Can not open an existing Excel worksheet

    or use another locale when you create COM object.
    --
    WBR, Vadims Podans
    MVP: PowerShell
    PowerShell blog - www.sysadmins.lv

    "TPGBrennan" <TPGBrennan@xxxxxx> rakstīja ziņojumā
    "news:F54768B6-19F2-4EDC-AAB2-85E2103FDDDD@xxxxxx"...

    > I have read through the previous posts on this forum for opening excel; I
    > have searched TechNet and read the various articles; I have the MS Windows
    > PowerShell Scripting Guide and nothing works.
    >
    > I am trying to open an existing Excel worksheet; the file exists and is
    > accessible to me.
    >
    > This line of code returns the following error:
    > PS C:\> $b = $xl.workbooks.open($file1)
    > Exception calling "Open" with "1" argument(s): "Old format or invalid type
    > library. (Exception from HRESULT: 0x80028018
    > (TYPE_E_INVDATAREAD))"
    > At line:1 char:24
    > + $b = $xl.workbooks.open( <<<< $file1)
    >
    > This line of code, which looks remarkably similiar, returns a different
    > error:
    > $workbook=$objexcel.workbooks.open($file1)
    > You cannot call a method on a null-valued expressio
    > At C:\test4.ps1:4 char:35
    > + $workbook=$objexcel.workbooks.open( <<<< $file1)
    >
    > Both were preceded by a definition of $file1 and the new-object
    > excel.application command. Is it possible to open an Excel 2003 worksheet
    > in
    > Powershell 1?

      My System SpecsSystem Spec

  5. #5


    Vadims Podans [MVP] Guest

    Re: Can not open an existing Excel worksheet

    or you can set another locale when you create COM object.
    --
    WBR, Vadims Podans
    MVP: PowerShell
    PowerShell blog - www.sysadmins.lv

    "TPGBrennan" <TPGBrennan@xxxxxx> rakstīja ziņojumā
    "news:F54768B6-19F2-4EDC-AAB2-85E2103FDDDD@xxxxxx"...

    > I have read through the previous posts on this forum for opening excel; I
    > have searched TechNet and read the various articles; I have the MS Windows
    > PowerShell Scripting Guide and nothing works.
    >
    > I am trying to open an existing Excel worksheet; the file exists and is
    > accessible to me.
    >
    > This line of code returns the following error:
    > PS C:\> $b = $xl.workbooks.open($file1)
    > Exception calling "Open" with "1" argument(s): "Old format or invalid type
    > library. (Exception from HRESULT: 0x80028018
    > (TYPE_E_INVDATAREAD))"
    > At line:1 char:24
    > + $b = $xl.workbooks.open( <<<< $file1)
    >
    > This line of code, which looks remarkably similiar, returns a different
    > error:
    > $workbook=$objexcel.workbooks.open($file1)
    > You cannot call a method on a null-valued expressio
    > At C:\test4.ps1:4 char:35
    > + $workbook=$objexcel.workbooks.open( <<<< $file1)
    >
    > Both were preceded by a definition of $file1 and the new-object
    > excel.application command. Is it possible to open an Excel 2003 worksheet
    > in
    > Powershell 1?

      My System SpecsSystem Spec

  6. #6


    rkd Guest

    RE: Can not open an existing Excel worksheet

    the following link is from a former thread in this newsgroup. may be it could
    bring you a little help, especially the part of MoW:
    http://www.microsoft.com/communities...f409365e8b&p=1



    "TPGBrennan" wrote:

    > I have read through the previous posts on this forum for opening excel; I
    > have searched TechNet and read the various articles; I have the MS Windows
    > PowerShell Scripting Guide and nothing works.
    >
    > I am trying to open an existing Excel worksheet; the file exists and is
    > accessible to me.
    >
    > This line of code returns the following error:
    > PS C:\> $b = $xl.workbooks.open($file1)
    > Exception calling "Open" with "1" argument(s): "Old format or invalid type
    > library. (Exception from HRESULT: 0x80028018
    > (TYPE_E_INVDATAREAD))"
    > At line:1 char:24
    > + $b = $xl.workbooks.open( <<<< $file1)
    >
    > This line of code, which looks remarkably similiar, returns a different error:
    > $workbook=$objexcel.workbooks.open($file1)
    > You cannot call a method on a null-valued expressio
    > At C:\test4.ps1:4 char:35
    > + $workbook=$objexcel.workbooks.open( <<<< $file1)
    >
    > Both were preceded by a definition of $file1 and the new-object
    > excel.application command. Is it possible to open an Excel 2003 worksheet in
    > Powershell 1?

      My System SpecsSystem Spec

Can not open an existing Excel worksheet problems?

Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel Worksheet Tabs Disappeared in vista 64 mozman_1970 Microsoft Office 6 22 May 2009
Finding the last row of and excel worksheet. GBPackerBacker VB Script 7 31 Mar 2009
How to determin a worksheet exist in Excel? Michael Gao PowerShell 5 15 Jun 2008
WM won't show OLE Object: Microsoft Office Excel Worksheet daissy Vista mail 12 19 Nov 2007
Excel Worksheet Guy Thomas PowerShell 2 08 Nov 2006