web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Create borders for a s...
Power Automate
Unanswered

Create borders for a specific range in Excel using Power Automate Desktop

(0) ShareShare
ReportReport
Posted on by 2
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 OR Robin\yn3rhhsht1a.tmp(8, 13) Microsoft VBScript compilation error: Expected end of statement

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
  • CU31080729-3 Profile Picture
    502 Moderator on at

    Hi,PriyaSekar_21

    you can try this following code its work for you:- 

     

    ' Create an instance of the Excel application object
    Set objExcel = CreateObject("Excel.Application")

    ' Open the Excel workbook (replace with your actual file path)
    Set objWorkbook = objExcel.Workbooks.Open("%ExcelFile%")

    ' Get a reference to the first worksheet (replace with the actual sheet name)
    Set objWorksheet = objWorkbook.Sheets("Sheet1")

    ' Define the range A1:C3
    Set objRange = objWorksheet.Range("A1:C3")

    ' Apply a border to the range
    objRange.Borders.LineStyle = 1 ' 1 corresponds to a thin line border

    ' Save and close the workbook
    objWorkbook.Save
    objWorkbook.Close

    ' Quit the Excel application
    objExcel.Quit

     

     

    (Note:- if you got your solution you can mark as solution and gives kudos)

     

    Thanks & Regards

    chetan ninghot

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Automate

#1
Mohsin Ali Profile Picture

Mohsin Ali 426

#2
11manish Profile Picture

11manish 308 Super User 2026 Season 2

#3
M Bilal Khan Profile Picture

M Bilal Khan 159

Last 30 days Overall leaderboard