I'm a beginner in powershell
$test = ("=7*" + $newWorkSheet.Cells.Item($indexDate,9).Text + "+DATE(" + $newWorkSheet.Cells.Item($indexDate,8).Text + ";1;3)-WEEKDAY(DATE(" + $newWorkSheet.Cells.Item($indexDate,8).Text + ";1;3))-2")
$newWorkSheet.Cells.Item($indexDate,1) = $test
Result to an incomprehensive error : Exception de HRESULT : 0x800A03EC
this is what I want to put in my cell :
echo $test
=7*40+DATE(2014;1;3)-WEEKDAY(DATE(2014;1;3))-2
How can i resolve it ? Thx ! and sorry for my poor english :'(
Edit
I did :
$test = '=7*' + $newWorkSheet.Cells.Item($indexDate,9).Text + '+DATE(' + $newWorkSheet.Cells.Item($indexDate,8).Text + ';1;3)-WEEKDAY(DATE(' + $newWorkSheet.Cells.Item($indexDate,8).Text + ';1;3))-2'
if I echo $test I got what I want :
=7*40+DATE(2014;1;3)-WEEKDAY(DATE(2014;1;3))-2
but when i put $test into my cell like this :
$newWorkSheet.Cells.Item($indexDate,1) = $test
Result an error :
Exception de HRESULT : 0x800A03EC
Au caractère D:\Users\sadm\Documents\salesforce_1.ps1:839 : 1
+ $newWorkSheet.Cells.Item($indexDate,1) = $tmp1
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OperationStopped: (:) [], COMException
+ FullyQualifiedErrorId : System.Runtime.InteropServices.COMException
I search to display a specific date with a number of week and a year.
Number of week and year are containing in cells of an excel.
$newWorkSheet.Cells.Item($indexDate,9) = $idsem ##Here is my number of week
$newWorkSheet.Cells.Item($indexDate,8) = $tempDate3.ToString("yyyy")
$test = "=" + "7*" + $newWorkSheet.Cells.Item($indexDate,9).Text + '+DATE(' + $newWorkSheet.Cells.Item($indexDate,8).Text + ';1;3)-JOURSEM(DATE(' + $newWorkSheet.Cells.Item($indexDate,8).Text + ';1;3))-2'
$newWorkSheet.Cells.Item($indexDate,1) = $test
$newWorkSheet.Cells.Item($indexDate,1).NumberFormat = "jj/mm/aaaa"
$global:indexDate++
When I launch the script with powershell 5.0 I had this error :
Exception de HRESULT : 0x800A03EC
Au caractère D:\Users\sadm\Documents\salesforce_1.ps1:831 : 1
+ $newWorkSheet.Cells.Item($indexDate,1) = $test
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OperationStopped: (:) [], COMException
+ FullyQualifiedErrorId : System.Runtime.InteropServices.COMException
with 2.0 that works...
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.