+ Reply to Thread
Results 1 to 5 of 5

1004 Application-defined or object-defined error using Border(X).linestyle

  1. #1
    Registered User
    Join Date
    02-18-2005
    Posts
    3

    Unhappy 1004 Application-defined or object-defined error using Border(X).linestyle

    All,

    Am sending some data from Access to Excel and getting an Access macro to do al the necessary formatting for me. Have managed to get fonts, shading & alignment as desired, but when using

    Please Login or Register  to view this content.
    I get a runtime 1004, "Application-defined or object-defined error" message on the third line.

    Any ideas why? Since it just so happened that some kludgy copy 'n' PasteSpecial would achieve the right end for me, I tried that too and got the "PasteSpecial method of Range class failed" error.

    So, am I not telling Access the right kind of object, range, or somesuch?

    Any ideas appreciated,

    Rich

    Update:
    Had a go at implementing Dave's suggestion of ranges & a separate sub as in thread 333724 but no dice: I now get compile errors when running any of my code!
    Last edited by leeds55; 02-18-2005 at 10:35 PM.

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258
    Hello Leeds55,

    Your code:

    .Selection.Borders(xlDiagonalDown).LineStyle = xlNone

    Correction:

    .Selection.Borders(xlDiagonalDown).LineStyle = xlLineStyleNone

    You used the wrong constant name. Easy to do.

    Regards,
    Leith Ross

  3. #3
    Registered User
    Join Date
    02-18-2005
    Posts
    3
    Mornin' Leith

    Quote Originally Posted by Leith Ross
    Correction:

    .Selection.Borders(xlDiagonalDown).LineStyle = xlLineStyleNone

    You used the wrong constant name. Easy to do.
    Thanks for the correction, but I'm afraid I'm still getting exactly the same error on exactly the same line.

    Any other thoughts you could suggest?

    Just for the record, VB tells me it's 6.3, Access 2003 & Excel 2003. I was hoping the tooltip on the constant name might alert me if I was using it wrong, but before & after your suggestion, the tooltip read <constantname>=Empty

  4. #4
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258
    Hi Leeds55,

    Wow. Open the VBA editor and use the object browser to search all libraries for the constant. If it doen't find it then either something is corrupt or there is a undocmented feature (i.e. bug) we don't about.

    BEst,
    Leith

  5. #5
    Registered User
    Join Date
    02-18-2005
    Posts
    3

    Solution: use a different method!

    I found the constant (in Excel only, though you'd think that'd do it) as xlLineStyleNone, so I'm pretty much foxed. The only thought I have is that I might have had to do a slightly different "With" first: I think I was only in an Excel.Application, and I wonder whether the worksheet would have been better.

    Anyway, my workaround was to take an empty cell from somewhere else in the spreadsheet & paste it into the range I didn't want borders for. Yes, that's a real kludge.

    Where I did want borders, I used
    Please Login or Register  to view this content.
    For each cell that needed them. Possibly not a scalable solution, but it worked in this instance, actually leaving me with less code than I had before.

    So, pretty happy. Thanks for the suggestion, Leith - at the very least it gave me another search term that led me to a solution!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1