Results 1 to 7 of 7
  1. #1
    RayMilhon is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2011
    Location
    Southern California
    Posts
    1,071

    Formatting Bordes around an Excel Cell

    I have an Access 2010 Database That exports Data to several Worksheets in an Excel 2010 Spreadsheet

    One of the requirements is that each cell needs to have a border on all 4 sides. I've tried everything I can find and nothing works. Anybody know how I can set the borders of the cell in Access VBA?

    Some of the things I've tried

    1. cell.BorderAround LineStyle = xlContinuous, Weight:=xlThin
    2. cell.Borders (xlAll)


    3. With Cell.Borders
    .Linestyle = xlcontinuous
    .Weight = xlMedium
    .Color = RGB(255,255,255)
    End With

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    This is Excel automation. Must set and open Excel objects.

    Bing: Access VBA Excel automation formatting

    Here is one https://stackoverflow.com/questions/...cess-using-vba
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    RayMilhon is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2011
    Location
    Southern California
    Posts
    1,071

    Formatting Borders around an Excel Cel

    Quote Originally Posted by June7 View Post
    This is Excel automation. Must set and open Excel objects.

    Bing: Access VBA Excel automation formatting

    Here is one https://stackoverflow.com/questions/...cess-using-vba
    I've done that. It all works perfectly each worksheet populates as it should the only issue I'm having is that the cells are supposed to have borders around each cell and they don't.

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    This worked for me:
    Code:
    Sub getExcelData()
    Dim xl As Excel.Application, wb As Excel.Workbook
    Set xl = CreateObject("Excel.Application")
    Set wb = xl.Workbooks.Open("C:\Users\June\Condos.xlsx")
    xl.Visible = True
    With wb.Worksheets("Sheet1")
        .Rows("1:1").Font.Bold = True
        With .Range("A1:E1").Borders
            .LineStyle = xlContinuous
            .Weight = xlMedium
            .Color = RGB(255, 255, 255)
        End With
    End With
    End Sub
    
    Why a white border?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    RayMilhon is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2011
    Location
    Southern California
    Posts
    1,071
    Maybe that's my Error I thought RGB(255,255,255) was black

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    Use RGB(0,0,0) or vbBlack
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  7. #7
    RayMilhon is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2011
    Location
    Southern California
    Posts
    1,071
    Maybe that's my Error I thought RGB(255,255,255) was black

    Yep That was it. Thanks for the help

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Import Excel data cell by cell into an Access table.
    By russmann2000 in forum Import/Export Data
    Replies: 3
    Last Post: 03-21-2018, 07:18 PM
  2. formatting a complete cell
    By Kevin Ensign in forum Reports
    Replies: 11
    Last Post: 08-02-2016, 05:32 PM
  3. Data from Excel has Alt enter in a cell
    By newbee in forum Reports
    Replies: 1
    Last Post: 03-14-2013, 12:09 PM
  4. Importing cell notes from excel
    By timmy in forum Import/Export Data
    Replies: 1
    Last Post: 03-12-2011, 01:34 PM
  5. Can we post Access cell data to Excel cell properties?
    By Zethro in forum Import/Export Data
    Replies: 1
    Last Post: 12-13-2005, 08:42 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums