Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

How to change excel worksheet tab color

0 Kudos
659

Hi experts,

I want to set excel worksheet color by ole2 object, how can I do this ?

Regards,

Spencer

1 ACCEPTED SOLUTION

Sandra_Rossi
Active Contributor
0 Kudos
536

Excel macro recorder gives that:

Sub Macro1()
'
' Macro1 Macro
'

    Sheets("Sheet1").Select
    With ActiveWorkbook.Sheets("Sheet1").Tab
        .ThemeColor = xlThemeColorAccent1
        .TintAndShade = 0
    End With
End Sub

You just convert it manually into ABAP, see there from step 8 (or from step 1 to record again yourself the actions you wish): https://blogs.sap.com/2012/05/15/copying-data-from-microsoft-excel-to-abap-using-ole/

5 REPLIES 5

former_member598787
Participant

0 Kudos
536

Hi expert,

My code is ole object not XML code like follow,

CREATE OBJECT h_excel 'EXCEL.APPLICATION'.
*--- get list of workbooks, initially empty
CALL METHOD OF
h_excel
'Workbooks' = h_mapl.
SET PROPERTY OF h_excel 'Visible' = 1.
CALL METHOD OF
h_mapl
'Add' = h_map.
gv_sheet_name = iv_name.
GET PROPERTY OF h_excel 'ACTIVESHEET' = worksheet.
SET PROPERTY OF worksheet 'Name' = gv_sheet_name .

0 Kudos
536

Please use the COMMENT button for comments, questions, adding details, replying to a comment or a proposed solution or to the OP question, etc., ANSWER is only to propose a solution, dixit SAP text at the right of the answer area.

Sandra_Rossi
Active Contributor
0 Kudos
537

Excel macro recorder gives that:

Sub Macro1()
'
' Macro1 Macro
'

    Sheets("Sheet1").Select
    With ActiveWorkbook.Sheets("Sheet1").Tab
        .ThemeColor = xlThemeColorAccent1
        .TintAndShade = 0
    End With
End Sub

You just convert it manually into ABAP, see there from step 8 (or from step 1 to record again yourself the actions you wish): https://blogs.sap.com/2012/05/15/copying-data-from-microsoft-excel-to-abap-using-ole/

0 Kudos
536

CREATE OBJECT h_excel 'EXCEL.APPLICATION'.
CALL METHOD OF
h_excel
'Workbooks' = h_mapl.
SET PROPERTY OF h_excel 'Visible' = 1.
CALL METHOD OF
h_mapl
'Add' = h_map.

GET PROPERTY OF h_excel 'ACTIVESHEET' = worksheet.
GET PROPERTY OF worksheet 'Tab' = worktab.

SET PROPERTY OF worktab 'Color' = 255.