Results 1 to 4 of 4
  1. #1
    DMT Dave is offline VIP
    Windows 10 Access 2016
    Join Date
    May 2018
    Posts
    1,365

    Excel Code From Access

    Hi Guys, I am using the following code on a Excel Work Sheet,

    is there a method to add this from Access as i am creating a new file each day, this would be helpful ???

    Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
    Cancel = True
    Target.Interior.ColorIndex = 3
    End Sub

    NEXT SHEET CELL COLOUR



    Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, Cancel As Boolean)
    Cancel = True
    Target.Interior.ColorIndex = 4
    End Sub

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,550
    access wont work that way. it wont work on datasheet.

    you CAN put interior color on a form text box,
    but at GOT FOCUS, LOST FOCUS. Access does not have beforeRightClick.

  3. #3
    DMT Dave is offline VIP
    Windows 10 Access 2016
    Join Date
    May 2018
    Posts
    1,365
    Do you mean i can do something like on FormOpen me.txtGreen.BackColour = 3

    Then within the xlApp and xlWS something like

    .Worksheets(1).Columns("C10:C10").BackColour = Me.txtGreen
    ??

    Many Thanks

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Code in Access VBA can open and manipulate Excel objects. Review http://www.accessmvp.com/KDSnell/EXCEL_MainPage.htm

    However, referencing a textbox like that will only be helpful if the textbox has a value that can translate to a color code because Value is default property and your code does not specify any property.
    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.

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

Similar Threads

  1. Replies: 2
    Last Post: 08-10-2015, 11:53 AM
  2. Running Excel VB Code From Access
    By Rob_U in forum Access
    Replies: 4
    Last Post: 05-21-2015, 09:20 AM
  3. VBA code to export from Access to Excel
    By DATADUDE28 in forum Access
    Replies: 1
    Last Post: 11-03-2012, 01:39 PM
  4. Run Access code, from separate excel...
    By redbull in forum Programming
    Replies: 1
    Last Post: 10-16-2012, 08:50 AM
  5. Code to Update Excel from Access
    By portmancp in forum Programming
    Replies: 2
    Last Post: 03-10-2010, 03:06 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