![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
|
Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
br> br> |
| |||||||
![]() |
| | Thread Tools | Display Modes |
| | #1 (permalink) |
| Guest
Posts: n/a
| [REF] ????? I'm on XP SP2 with PowerShell V1. I have a script that has worked perfectly until now. When I ran it today it threw up all over my screen. I went line by line through it and found the offending line. $Word = New-Object -Com Word.Application #$files is an array of files. #$Savepath is the path to the files #Do some Stuff $SAVENAME=$SAVEPATH+'\'+$FILES[$I].BASENAME+'.DOC' ################OFFENDING LINE BELOW############## $Word.ACTIVEDOCUMENT.SAVEAS($SAVENAME) I get an error telling me i need to use [ref] if i change that line to $Word.ACTIVEDOCUMENT.SAVEAS([ref]$SAVENAME) It's fine. Ok great why did it break after months of no problems if I didn't change anything??? Thanks for any insights. |
| | #2 (permalink) | ||||||||||||
| Guest
Posts: n/a
| Re: [REF] ????? Did you install any patches or service packs for Word or did you upgrade office? It could be that a change external to PowerShell caused this. -- Kirk Munro Poshoholic http://poshoholic.com "Kuma" <kumasan76@xxxxxx> wrote in message news:2c32087b-46e8-415e-a369-f59d2bcd7e72@xxxxxx
| ||||||||||||
| | #3 (permalink) | ||||||||||||
| Guest
Posts: n/a
| Re: [REF] ????? Kirk Munro wrote:
I'll try to get it maybe overnight. -- Microsoft MVP - Windows PowerShell http://www.microsoft.com/mvp PowerGadgets MVP http://www.powergadgets.com/mvp Blog: http://marcoshaw.blogspot.com | ||||||||||||
| | #4 (permalink) | ||||||||||||||||||||||||||||||||||||||||||||||||
| Guest
Posts: n/a
| Re: ????? On Dec 17, 8:27 pm, "Kirk Munro" <so...@xxxxxx> wrote:
on a C# project I needed the Office Interop Classes. Now if I do the following: $word = New-Object -Comobject Word.Application $word.gettype()|Select Assembly,Namespace I get back: Assembly: Microsoft.Office.Interop.Word, Version=10.0.4504.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35 Namespace: Microsoft.Office.Interop.Word So it looks to me like New-Object is creating an instance of word.application from the Interop which is causing me to have to use [ref]. So how to I create a standard word.application without it coming from the Interop? | ||||||||||||||||||||||||||||||||||||||||||||||||
| | #5 (permalink) | ||||||||||||
| Guest
Posts: n/a
| Re: ?????
can tell, the only way to easily access Office via .NET (C#, PowerShell, etc.) is via the COM object, which is what you're doing. It seems even when you get the Office SDK, this is how any .NET language is used for Office programming. Marco | ||||||||||||
| |
| |