Hi @C_Haines_ENG
Implementing in VB.NET is a little harder than VBA. You will have to access objects in more depth adding the enumeration.
For Example this is how to access your original snippet in VB.NET and here is the link to the Weight enumeration
and the Border Enumeration
.Range("B2:E2").Borders(XlBordersIndex.xlEdgeBottom).Weight = XlBorderWeight.xlMedium Here is the working method in VB.Net
AddReference "Microsoft.Office.Interop.Excel" 'To use excel
Imports Microsoft.Office.Interop 'To use excel
Imports Microsoft.Office.Interop.Excel 'To use excel
Dim excelApp As Excel.Application = GetObject(, "Excel.Application")
Try
excelApp = CreateObject("Excel.Application")
Catch
MsgBox ("Cannot access excel.")
End Try
excelApp.Visible = True
excelApp.DisplayAlerts = False
Dim oWb As Workbook = excelApp.Workbooks.Add
Dim oWs As Worksheet = oWb.Worksheets(1)
With oWs
.Range("B2:E2").Value = "This is a new Excel value"
.Range("B2:E2").Columns.AutoFit
Try
.Range("B2:E2").Borders(XlBordersIndex.xlEdgeBottom).Color = RGB(255, 0, 0)
.Range("B2:E2").Borders(XlBordersIndex.xlEdgeBottom).Weight = XlBorderWeight.xlMedium
Catch
MessageBox.Show ("Error applying border.","iLogic")
End Try
End With
If this solved a problem, please click (accept) as solution.
Or if this helped you, please, click (like)
Regards
Alan