0

I am trying to run a VBscript through Power Automate Desktop to add borders to a certain range in an Excel Worksheet. I am not sure what I am doing wrong but I am getting an error saying Type Mismatch: Range.

I have attached the code here for reference. I am initializing the variable - Excel File with the file path

Dim Excel
Dim ExcelDoc
'Opens the Excel file
    Set Excel = CreateObject("Excel.Application")
    Set ExcelDoc = Excel.Workbooks.open("%ExcelFile%"
Dim myRange As Range
    Set myRange = Range(“A1:C3")

    With myRange.Borders
        .LineStyle = xlContinuous
        .Colorindex = 0
        .TintAndShade = 0
        .Weight = xlThin
    End With

'Closes the Excel file
Excel.ActiveWorkbook.Close

Excel.Application.Quit
2
  • 1
    Check the quote here ... Set myRange = Range(“A1:C3") ... the one next the left of A1 looks dodgearama. That's the first thing, also, where's the closing bracket next to %ExcelFile%? I'd suggest you need to maybe be explicit regarding the worksheet you want to get the range for as well. That's my suggestion.
    – Skin
    Commented Dec 19, 2023 at 2:05
  • Please try Run Excel Macro (VBA code) with PA desktop. Microsoft documentation: > Excel actions
    – taller
    Commented Dec 19, 2023 at 3:43

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.