So I want to work with a workaround temporarily. In this workaround, I want to use VB to color specific excel cells (and optionally take a screenshot of the excel sheet).
My input is a dictionary containing a list of cell ranges assigned with a color and the excel file of course.
My code sketch looks like this:
Dim objExcel
Set objExcel = CreateObject("Excel.Application")
objExcel.Application.Visible = True
objExcel.Application.DisplayAlerts = False
Dim objCombinedWb = objExcel.Workbooks.Open(in_FilePath)
Set ws = objCombinedWb.Worksheets(1)
For Each item As String In in_Colors.Keys()
If (in_Colors(item).ToLower().COntains("green"))
ws.Range(item).Interior.Color = Color.Green
Else
ws.Range(item).Interior.Color = Color.Red
End If
Next
ws.Save
Sys.Desktop.Picture.SaveToFile(in_ScreenshotFile)
However, i guess this is the VBScript approach and not the proper approach to the “Invoke code” command since this allows to directly input a dictionary.
How can i modify this code to be also suitable for the invoke code command?
Is it possible to loop through my input dictionary in an efficient way in powershell? I guess I would prefer a code solution rather than a powershell solution. However, if this isn’t possible, your solution looks quite neat!