Bonjour,
Voici ci-dessous un script powershell que j'ai tenté de compléter afin de générer automatiquement 1 fichier PDF par feuilles excel:
Code powershell : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14 Get-ChildItem . -Filter CRA*.xlsm | Foreach-Object { $wb=$excel.workbooks.open($_.FullName) $ws = $wb.Worksheets.Item("CRA") $ws.Activate() $FullName = ("CRA_") + ($wb.FullName) #Pour formater le nom du fichier PDF $ws.PrintOut("","", 1,"False","PDFCreator","True",$FullName) $ws.PrintOut() $ws = $wb.Worksheets.Item("PC") $ws.Activate() $ws.PrintOut() $FullName = ("PC_") + ($wb.FullName) #Pour formater le nom du fichier PDF $ws.PrintOut("","", 1,"False","PDFCreator","True",$FullName) $wb.Close($false) }
A l'exécution j'ai les erreurs suivantes:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13 Unable to get the PrintOut property of the Worksheet class At $file:20 char:3 + $ws.PrintOut("","", 1,"False","PDFCreator","True",$FullName) + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : OperationStopped: (:) [], COMException + FullyQualifiedErrorId : System.Runtime.InteropServices.COMException Exception calling "ReadKey" with "1" argument(s): "The method or operation is not implemented." At $file:2 char:70 + ... tter...") { Write-Host -NoNewLine $Message $null = $Host.UI.RawUI.Rea ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [], MethodInvocationException + FullyQualifiedErrorId : NotImplementedException
J'avoue ne pas maitriser du tout PowerShell, quelqu'un pourrait-il me venir en aide?
Merci
kondor76
Partager