cancel
Showing results for 
Search instead for 
Did you mean: 

MS Excel: Actions for aligning, bolding and underlining

JariKorkkinen
Level 3
Hello, I would need to do some cell formatting in Excel (aligning left+right+center, bolding, underlining) and apparently there is no way to do these with basic Excel VBO actions. Has somebody struggled with same thing and found a way to do these? I have very little knowledge of VB.NET but I´ve tried to write separate code stages for each of these actions but cannot get those working. Here´s a code example: ------------------------ Dim wb, excel, range As Object Try wb = GetWorkbook(Handle, Nothing).ActiveSheet excel = wb.Application range = excel.Selection range.HorizontalAlignment = xlRight Finally End Try ------------------------------- When I press Check Code I get error "Compiler error - xlRight is not defined". I assume it´s because required assembly and namespace are missing. I added Assembly: Microsoft.Office.Interop.Excel.dll and Namespace: Microsoft.Office.Interop.Excel. After that Check Code does not give error anymore. However when I try to run the process, it stops to the first step and gives an error: 23.5.2017 9:41:07 ACTION: 'Create instance' Process: 'AR Dunning New' Subsheet: 'Import Excel sheets to collections' ERROR: Internal : Could not run the object because one of the code stages has a compile error, use Check for Errors for a list of problems Any help would be highly appreciated! BR, Jari
4 REPLIES 4

JariKorkkinen
Level 3
Thanks a lot Bastiaan! That helped and now the code works.

Anonymous
Not applicable
Hi Jari,   Can you please share what did you do that helped ? I am getting a similar error.

Anonymous
Not applicable
Hi Jari,   Can you please share what did you do that helped ? I am getting a similar error.

Hitesh__Mhatre
Level 4
Hi Jari, You code for formatting is correct just need to put an numeric value for ""xlRight"".   Please refer below link to get all numeric values https://msdn.microsoft.com/en-us/library/microsoft.office.interop.excel…   Hope this resolves your issue.