Hello,
Try
$mailto = $workSheet.cells.Item(2, 2)
or
$mailto = $workSheet.cells.Item(2, 2).Value
If the answer is helpful, please click "Accept Answer" and kindly upvote it.
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hi all,
I'm working on a PowerShell script to read content in excel file hosted in SharePoint online in office 365.
My goal is retrieve content for cell B2 from the file.
My code so far,
$Excel = New-Object -ComObject Excel.Application
$Workbook = $Excel.Workbooks.Open("\\bernardcomms.sharepoint.com\sites\Test_Site\Documents\test_with_macro.xlsm")
$Excel.Workbooks.CheckOut("\\bernardcomms.sharepoint.com\sites\Test_Site\Documents\test_with_macro.xlsm")
# Get the first sheet in excel file
$workSheet = $Workbook.Sheets.Item(1)
$WorkSheet.Name
# Get value for cell B2
$mailto = $workSheet.cells.Item(2, 2).Text
$mailto.Text
On executing the script above, it just hangs. What am i doin wrong.
Hello,
Try
$mailto = $workSheet.cells.Item(2, 2)
or
$mailto = $workSheet.cells.Item(2, 2).Value
If the answer is helpful, please click "Accept Answer" and kindly upvote it.
Please try one of below to open workbook.
$WorkBook = $Excel.Workbooks.Open('https://bernardcomms.sharepoint.com/sites/Test_Site/Documents/test_with_macro.xlsm')
or
$WorkBook = $Excel.Workbooks.Open('\\bernardcomms.sharepoint.com@SSL\DavWWWRoot\sites\Test_Site\Documents\test_with_macro.xlsm')