Results 1 to 5 of 5
  1. #1
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Lewes, East Sussex, Sussex, United Kingdom
    Posts
    232
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Style problem (XL2000 SR1)

    Help - Excel is being very annoying. This code is producing run-time error 450 - invalid number of arguments or property assignation error :

    lngRow = !Rownumber
    intCol = !Column
    Set objXLRange = objXLSheet.Cells(lngRow, intCol)
    objXLRange.Style = "W032"

    The error occurs on the last line above. The styles have been merged from another workbook using :

    objXLBook.Styles.Merge Workbook:=objXLBookLookup


    Any ideas why this is not working ?

    Any help gratefully received

    Nick

  2. #2
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Weert, Limburg, Netherlands
    Posts
    4,812
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Style problem (XL2000 SR1)

    Change that to (from XL2000 Help):

    objXLRange.Style.Name="W032"
    Jan Karel Pieterse
    Microsoft Excel MVP, WMVP
    www.jkp-ads.com
    Professional Office Developers Association

  3. #3
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Lewes, East Sussex, Sussex, United Kingdom
    Posts
    232
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Style problem (XL2000 SR1)

    Thanks for the help, but adding the .Name produced the same error. I managed to find out that if you merge styles you have to reference the original workbook where the styles were defined.

    So this was the code that worked :

    objXLRange.Style = objXLBookLookup.Styles("WO32")

    A minor irritation is that when running this line of code :

    objXLBook.Styles.Merge Workbook:=objXLBookLookup

    Excel produces a dialog box to confirm over-writing existing styles with the same name, and I cannot find any way of avoiding this using code. Ah well.

  4. #4
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Weert, Limburg, Netherlands
    Posts
    4,812
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Style problem (XL2000 SR1)

    Not even with DisplayAlerts set to false?
    Jan Karel Pieterse
    Microsoft Excel MVP, WMVP
    www.jkp-ads.com
    Professional Office Developers Association

  5. #5
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Lewes, East Sussex, Sussex, United Kingdom
    Posts
    232
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Style problem (XL2000 SR1)

    That should do the trick. You learn something new every day.

    Thanks

    Nick

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •