Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

pshell, vista & office 2007

53 views
Skip to first unread message

n3llyb0y

unread,
Mar 9, 2007, 4:48:35 AM3/9/07
to
Hi All,

I've recently moved to Vista but one of my scripts that was using
office 2007 no longer wants to work. I was hoping someone could shed
some light on this.

I'm calling the excel application

$xl = new-object -comobject "excel.application"

Then try to add a new workbook

$xl.workbooks.add()

and get this error:

Exception calling "Add" with "0" argument(s): "Old format or invalid
type library. (Exception from HRESULT: 0x80028018 (TYPE_E_INVDATAREAD))

any ideas?

Cheers,
Neil

Brandon Shell

unread,
Mar 9, 2007, 9:31:12 AM3/9/07
to
Worked for me. I dont have office on my x64 Vista so I cant try that... are
you running x64?

--
Brandon Shell
---------------
Stop by my blog some time :)
Blog: http://www.bsonposh.com/
PSH Scripts Project: www.codeplex.com/psobject
--------------------------------------

"n3llyb0y" <n3ll...@aol.com> wrote in message
news:2007030909483416807-n3llyb0y@aolcom...

n3llyb0y

unread,
Mar 9, 2007, 9:59:43 AM3/9/07
to
On 2007-03-09 14:31:12 +0000, "Brandon Shell" <tshel...@gmail.com> said:

> Worked for me. I dont have office on my x64 Vista so I cant try that...
> are you running x64?

No, not using x64.

So it worked on your x86 setup? I think I'll go ahead and re-install
powershell and office.

Thanks for confirming :-)

n

RichS

unread,
Mar 10, 2007, 3:58:00 PM3/10/07
to
I've got the same error. be interested if you find a solution
--
Richard Siddaway
Please note that all scripts are supplied "as is" and with no warranty
Blog: http://richardsiddaway.spaces.live.com/
PowerShell User Group: http://www.get-psuguk.org.uk

RichS

unread,
Mar 10, 2007, 4:01:03 PM3/10/07
to
Interestingly

Set objExcel = CreateObject("Excel.Application")

objExcel.Visible = True
objExcel.Workbooks.Add


objExcel.Cells(1, 1)= "Computer"
objExcel.Cells(1, 2)= "OU"

works when run in vbscript


--
Richard Siddaway
Please note that all scripts are supplied "as is" and with no warranty
Blog: http://richardsiddaway.spaces.live.com/
PowerShell User Group: http://www.get-psuguk.org.uk

Brandon Shell

unread,
Mar 10, 2007, 6:31:41 PM3/10/07
to
Very Odd Rich... it works for me on two different machines. Are you using
beta Office or something? What version of office?

"RichS" <Ri...@discussions.microsoft.com> wrote in message
news:889BAE28-C125-4A51...@microsoft.com...

RichS

unread,
Mar 11, 2007, 12:42:02 PM3/11/07
to
As far as I'm aware its not beta. It's a work machine so need to check on
office version. I installed powershell on top of office - wonder if that
matters.

As vbscript works OK - it suggests the interop isn't registered correctly


--
Richard Siddaway
Please note that all scripts are supplied "as is" and with no warranty
Blog: http://richardsiddaway.spaces.live.com/
PowerShell User Group: http://www.get-psuguk.org.uk

RichS

unread,
Mar 11, 2007, 12:49:00 PM3/11/07
to
Done a bit of digging and found this

http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=168710&SiteID=1

look at the bottom posting in the thread. I'm just going to test it


--
Richard Siddaway
Please note that all scripts are supplied "as is" and with no warranty
Blog: http://richardsiddaway.spaces.live.com/
PowerShell User Group: http://www.get-psuguk.org.uk

RichS

unread,
Mar 11, 2007, 1:26:17 PM3/11/07
to
OK - think I've cracked it.

have a look at this KB article

http://support.microsoft.com/default.aspx?scid=kb;en-us;320369

The problem is the culture the machine is set to. I'm in the UK so have
en-GB - that clashes with Excel's en-US so won't work. I've chnaged all my
location info to US and it now works. $host.currentculture shows en-US

the code

$xl = New-Object -comobject "excel.application"
$xl.workbooks.add()

now works. Brandon - I think you are US based so thats why it worked.

Fix is to install MUI pack or to modify code in KB article for powershell.
Easiest is to use MUI

--
Richard Siddaway
Please note that all scripts are supplied "as is" and with no warranty
Blog: http://richardsiddaway.spaces.live.com/
PowerShell User Group: http://www.get-psuguk.org.uk

Brandon Shell

unread,
Mar 11, 2007, 3:16:03 PM3/11/07
to
gj Rich. See... curiosity doesn't always kill that cat.

"RichS" <Ri...@discussions.microsoft.com> wrote in message

news:2954C28A-B83A-44C7...@microsoft.com...

Adam Geras

unread,
Mar 11, 2007, 10:20:05 PM3/11/07
to
Entering the conversation late, but you can also use reflection and pass in
'en-US' culture as a parameter ... see DataLib.ps1 from PSExpect for what I
did with Excel for data-driven testing with PowerShell
(http://www.codeplex.com/psexpect).

RichS

unread,
Mar 12, 2007, 12:24:10 PM3/12/07
to
To draw a close to this one - it turns out that the Office 2007 MUI won't be
available until later in the year. Picking up on Adams post I finally got
this to work

$xl = New-Object -comobject "excel.application"

$xl.visible = $true
$xlbooks =$xl.workbooks
$newci = [System.Globalization.CultureInfo]"en-US"
$xlbooks.PSBase.GetType().InvokeMember("Add",
[Reflection.BindingFlags]::InvokeMethod, $null, $xlbooks, $null, $newci)

Thanks Adam I'd been really struggling with the last bit.


--
Richard Siddaway
Please note that all scripts are supplied "as is" and with no warranty
Blog: http://richardsiddaway.spaces.live.com/
PowerShell User Group: http://www.get-psuguk.org.uk

0 new messages