Results 1 to 2 of 2
  1. #1
    mp3909 is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Feb 2018
    Posts
    136

    Refering to Excel Spreadsheet va Access VBA

    My code is always error-ing at the comment section in the code below.

    Code:
    Public Sub formatExcelReports(ByRef myDict As Dictionary)
    Dim xlApp As Object
    Set xlApp = CreateObject("Excel.Application")
    xlApp.Visible = True
    Dim xlWbk As Object
    Dim Key As Variant
    Dim ws As Object
    For Each Key In myDict.Keys
        Debug.Print Key & vbTab & dict(Key)
        Set xlWbk = xlApp.workbooks.Open(Key, False, False)
        For Each ws In xlWbk.sheets
            With ws.cells
                .Font.Name = "Arial"
                .Font.Size = 10
            End With
            On Error GoTo eh
            ws.Range("A1:" & Split(ws.Range("A1").end(xlToRight), "$")(1) & 1).Interior.Color = RGB(191, 191, 191)    'here it goes to the error handler
        Next
    Next
    eh:
        MsgBox "error"
        Resume Next
    End Sub


  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,525
    try a less complicated range,
    try: ws.range("A1:B2").interior.color=…

    (cause I'm betting its your big formula)

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

Similar Threads

  1. Format an Excel spreadsheet from Access
    By crowegreg in forum Programming
    Replies: 4
    Last Post: 12-23-2013, 07:12 PM
  2. Creating excel spreadsheet from access vba
    By nyneave in forum Programming
    Replies: 1
    Last Post: 10-12-2012, 09:59 AM
  3. How to import excel spreadsheet into an Access subform
    By upfish in forum Import/Export Data
    Replies: 1
    Last Post: 10-03-2012, 01:53 PM
  4. Open Excel spreadsheet in Access
    By carlyd in forum Forms
    Replies: 1
    Last Post: 02-17-2012, 01:09 PM
  5. Email Excel Spreadsheet from Access
    By Nancy in forum Access
    Replies: 2
    Last Post: 11-09-2010, 02:37 PM

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