I hope you can help me with my PowerShell problem. I want to use the Set-Clipboaed and Get-Clipboard commands from PowerShell to copy specific rows from my excel file in two different textfields in a specific browser site.
The problem is that I always get the content copied from the rows in my excel file, only in the first textfield. For example: The content of row A1 is "Hello" and the content from row A2 is "World". If I copy the rows in the textfields of the browser site, both Strings "Hello" "World" will be displayed only in textfield1. My goal is to have the string "Hello" in textfield1 and the string "World" in textfield2 and later to have a command to use keys on my keyboard to paste the content like in KeePass with the credentials.
Here's what I've done so far. I used a little help from the site https://lazywinadmin.com/2014/03/powershell-read-excel-file-using-com.html and tried to split both rows in two different strings and then tried to copy both string with "Get-Clipboard" in the browser site.
#Specify the path of the excel file
$FilePath = "PathToMyExcelFile\Test-Excel-Auto2.xlsx"
#Specify the Sheet name
$SheetName = "table1"
# Create an Object Excel.Application using Com interface
$objExcel = New-Object -ComObject Excel.Application
#$objExcel = new-object -c excel.application
# Disable the 'visible' property so the document won't open in excel
$objExcel.Visible = $false
# Open the Excel file and save it in $WorkBook
$WorkBook = $objExcel.Workbooks.Open($FilePath)
# Load the WorkSheet 'BuildSpecs'
$WorkSheet = $WorkBook.sheets.item($SheetName)
Set-Clipboard $WorkSheet.Range("A1").Text
Set-Clipboard $WorkSheet.Range("A2").Text -Append
(Get-Clipboard) -split "'n'"
# Get-Clipboard) -split '\t|\r?\n'
# Get-Clipboard.Split ( "'\t|\r?\n'")
# Set-Clipboard $WorkSheet.Range("A1").Text
# $variable = Get-Clipboard
# Set-Clipboard $WorkSheet.Range("A2").Text -Append
# $variable2 = Get-Clipboard
I miss the part, how to get both strings copied in the two different textfields in my browser site.
Thanks in advance for your help.
MarT22