Where did I go wrong here? I am trying to copy the chart from excel and save it to a local so I can insert that chart pic into an HTML e-mail. It is coping as I can paste it, but each time it runs I still get the Clipboard contains no image" error
Set-ExecutionPolicy Unrestricted -Scope CurrentUser
$connectstring = "Connection"
$path = "C:?blah blah blah"
Set-ExecutionPolicy Unrestricted
#Temp File Path
$pathtmp = "C:Temp path"
#Archive
$patharc = "C:Temp patharc"
#Set the output File Name
$name = "Same_Image_test"
#Local Path
$localpath ="C:\PowerShellScripts\"
$timer = (Get-Date -Format MM-dd-yyy-hh-mm)
$errorlog = $localpath + "Logs\" + $name + ".log"
$filename = $path + $name + ".csv"
$filenametemp = $localpath + "CSVOutput\" + $name + "-" +$timer + "-temp.csv"
$localfilename = "Q:\Temp.xlsx"
$archive = $patharc + $name + "-archive-from-" + $timer + ".csv"
#Start Logging
Start-Transcript -Path $errorlog -Append
Add-Type -AssemblyName System.Windows.Forms
set-itemProperty -Path $localfilename -Name IsReadOnly -Value $false
$app = New-Object -comobject Excel.Application
$app.Visible = $True
##IS NOT READONLY?
set-itemProperty -Path $localfilename -Name IsReadOnly -Value $false
$wb = $app.Workbooks.Open("Q:\temp.xlsx")
Set-Clipboard
## WAIT ONE MIN
Start-Sleep 20
$wb.Name
$wb.RefreshAll()
Start-Sleep 20
$wb.RefreshAll()
#Copy Chart
$ws = $wb.worksheets.item("Chart")
$image = $ws.ChartObjects().copyPicture()
#$chart = $ws.Selection.PasteSpecial()
Start-Sleep 5
$wb.Save()
$wb.Close()
$app.Quit()
#Copy Chart
$ws = $wb.worksheets.item("Chart")
$image = $ws.ChartObjects().copyPicture()
Edited to add code before I try and paste the image