Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

SOLVED: Powershell with argument/parameter

Jennifer Roach:

I need to execute a word Macro using Powershell. So far I have


$wd = new-object -comobject word.application
$wd.run("PrintAll")
$wd.quit()

What I would like to do is add a parameter or argument that will point to a specific folder on the network and then pass that parameter to the macro. The macro starts like this:


Public sPath
Sub PrintAll()

Dim fs, f, fc, f1
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFolder(sPath) ' Provide folder name where doc files are present
Set fc = f.Files
Dim FileList() As String
Dim Cnt As Integer
Cnt = 0
Dim myDoc As Word.Document

I have about 70 different folder locations that I need to point to, and the goal is to only have 1 Sub (macro) in Word, but to have separate powershell scripts that point to each of the folders and pass them to the one Sub (macro).

Any thoughts on how I can achieve this?

I tried


$wd = new-object -comobject word.application
$wd.run('PrintAll', '\\serverX\g$\xxxxxxxx')
$wd.quit()

But got error "Argument: '2' should be a System.Management.Automation.PSReference. Use [ref]."



Posted in S.E.F
via StackOverflow & StackExchange Atomic Web Robots
This Question have been answered
HERE


This post first appeared on Stack Solved, please read the originial post: here

Share the post

SOLVED: Powershell with argument/parameter

×

Subscribe to Stack Solved

Get updates delivered right to your inbox!

Thank you for your subscription

×