Pash-Project / Pash

An Open Source reimplementation of Windows PowerShell, for Mono.
https://groups.google.com/group/pash-project
BSD 3-Clause "New" or "Revised" License
517 stars 54 forks source link

Can Pash handle creating a word document? #65

Open abbood opened 11 years ago

abbood commented 11 years ago

I'm new to Powershell scripting, but I need it to complete a task on mac..

I was wondering if this library (which is marked pre-alpha) can handle something like this:

$wd = New-Object -ComObject Word.Application
$wd.Visible = $true
$doc = $wd.Documents.Open($filename)
$doc.Tables | ForEach-Object {
  $_.Cell($_.Rows.Count, $_.Columns.Count).Range.Text
}

I've tried using this code on pash, but then it gives me all sorts of errors like

ERROR: $objWord.Visible (generic_token)
ERROR: Exception has been thrown by the target of an invocation.

So to make a long painful story short, is Pash as it stands today capable of executing the above code?

I just want to make node.js spawn a pash process, that parses a word doc containing a table, and return the value back to my node.js process..

staxmanade commented 11 years ago

I don't know the effort it would take to get going, but it does appear as though it may be possible to implement this functionality.

This project leverages the Mono framework heavily and I just found this page http://www.mono-project.com/COM that describes mono interacting with COM. I don't know if COM on the Mac works the same as on windows, or if/how Mono makes it work, but this would be an awesome feature to get into the project.

JayBazuzi commented 11 years ago

To directly answer your question: Pash as it stands today is not capable of executing the above code.

If you can write C# code that does this on the Mac, then we can probably make it work in Pash. I had assumed that Word for the Mac didn't do COM, but let's hope I'm wrong about that. :-)

alesliehughes commented 11 years ago

COM doesn't exist on the the Mac. However, if you use Crossover + MS for Windows it might be possible. COM support in mono isn't fully implemented, so you can only try.