Bonjour,
J'ai ce bout de code:
1 2 3 4 5 6 7 8 9 10 11 12 13
| $excel=new-object -com excel.application
Get-ChildItem . -Filter *.xlsm | Foreach-Object {
$wb=$excel.workbooks.open($_.FullName)
$ws = $wb.Worksheets.Item("Nom1")
$ws.Activate()
$ws.PrintOut()
$ws = $wb.Worksheets.Item("Nom2")
$ws.Activate()
$ws.PrintOut()
# $ws.PrintOut( , , 1, False, "PDFCreator", False, "test2" )
$wb.Close($false)
} |
You cannot call a method on a null-valued expression
$wb=$excel.workbooks.open($_.FullName)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
$ws = $wb.Worksheets.Item("Nom1")
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
J'ai ce retour sur toutes les fonctions appelées....
Une idée?
Si je suis pas sur le bon forum,merci de me le dire....
Je suis sur windows 10
Name Value
---- -----
PSVersion 5.1.16299.1146
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.16299.1146
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
Merci
kondor76
Partager