Several things which I can think about
- Try to trim the text from excel cell just in case you have a empty spaces in there:
- Try to cast the values to a specific type (it may be failed because of a wrong type of the value)
swLayer.Style = CInt(xlws.Cells(k, 4).Value)
swLayer.Width = CInt(xlws.Cells(k, 5).Value)
- What is the type of your color cell in the Excel? You might need to convert it to COLORREF long
I have verified that the layers APIs work correct. Here is the example which you can use for a reference: #CODE|Edit Layers Properties
If you send me a sample of your spreadsheet I might be able to help you, but I think this is something related to the values types returned from the spreadsheet.
In addition, the macro adds new layer using the values from the same spreadsheet but it doesn't update the existing layers properties.