Page 2 of 2 FirstFirst 12
Results 16 to 25 of 25
  1. #16
    crowegreg is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Posts
    398

    That's not good. I spent a good amount of time yesterday researching this problem. It seems simple, but I can't figure out a solution. Thanks for your assistance!!

  2. #17
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    Quote Originally Posted by crowegreg View Post
    ... I spent a good amount of time yesterday researching this problem....
    I know what you mean. Obviously this problem is above my pay scale.

  3. #18
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    crow, how does my suggested code edit create another instance of Excel object? I actually did not test from Access, I tested VBA creating the textbox and setting the formula from Excel.

    ItsMe, for manual test, create the textbox from the tool on the ribbon Insert tab. Don't want to see blinking cursor within the textbox frame. Once the textbox is selected, click into the formula bar. It does seem your TextFrame is something different.
    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.

  4. #19
    crowegreg is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Posts
    398
    Every time I make a change to the code, after running the process, I confirm that no instance of Excel is running.

    When I add the line of code of:
    shapeExcel.select , then run the process, there is no instance of Excel open.

    Then when I add the line of code:
    Selection.formula = "='Auto Submit Calculations'!B3", then run the process, there is an instance of Excel open

    What did I do wrong?

  5. #20
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    Quote Originally Posted by June7 View Post
    ...ItsMe, for manual test, create the textbox from the tool on the ribbon Insert tab. Don't want to see blinking cursor within the textbox frame. Once the textbox is selected, click into the formula bar. It does seem your TextFrame is something different.
    This is what I did from word go. What I did not do was use an expression like "=A1"

    So
    =A1+A2

    Does not work when I have Excel open and I use the Ribbon to add a Text Box but
    =A1
    Does work

    I am starting to see that there just is not a method for the Text Box object (from within Access) that adds the formula to the object. Perhaps giving the object a name (or using the name or index from the parent object) is a solution, not sure.

  6. #21
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    The textbox cannot have a complex formula, all it can do is reference a cell. The cell must have formula and do the calculation.

    crow's 'formula' is just a reference to cell on another sheet.
    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. #22
    crowegreg is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Posts
    398
    ItsMe, so create an object for the text box, and see if this makes any difference?

  8. #23
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    Earlier, I gave it another go from Access, using VBA. I was unable to find a property that was within scope to edit the formula. I tried a few things like, Formula, Caption, Characters, and some others. The only other thing I can think of trying now would be to create a Chart object and use the chart object as a parent to a textbox and see if that helps.

    I was looking online and saw mention of ActiveX vs plain Jane TextBox. Not sure if there is any benefit of one over the other with regard to your needs.

  9. #24
    crowegreg is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Posts
    398
    I figured out a workaround. With not being able to set the textbox to refer to another cell within the workbook, I decided to use the variables that were within the form that were the values of the cells in question.
    Here's the finished code.

    Dim xlApp As Object
    Dim wbExcel As Object
    Dim sheetExcel As Worksheet
    Dim shapeExcel As Shape
    Dim wb1 As Workbook

    Set xlApp = New Excel.Application
    'xlApp.Visible = True

    Set wb1 = xlApp.Workbooks.Open(Environ$("USERPROFILE") & "\documents\" & strFileName & ".xlsx")
    Set sheetExcel = wb1.Sheets(1)

    'Auto Submit WE1 Textbox
    Set shapeExcel = sheetExcel.Shapes.AddLabel(msoTextOrientationHoriz ontal, 617, 70, 35, 35)
    shapeExcel.Select
    shapeExcel.TextFrame2.TextRange.Characters.Text = dblASCountWE1

    'Auto Submit WE2 Textbox
    Set shapeExcel = sheetExcel.Shapes.AddLabel(msoTextOrientationHoriz ontal, 740, 70, 35, 35)
    shapeExcel.Select
    shapeExcel.TextFrame2.TextRange.Characters.Text = dblASCountWE2

    'Auto Approved WE1 Textbox
    Set shapeExcel = sheetExcel.Shapes.AddLabel(msoTextOrientationHoriz ontal, 617, 425, 35, 35)
    shapeExcel.Select
    shapeExcel.TextFrame2.TextRange.Characters.Text = dblAACountWE1

    'Auto Approved WE2 Textbox
    Set shapeExcel = sheetExcel.Shapes.AddLabel(msoTextOrientationHoriz ontal, 740, 425, 35, 35)
    shapeExcel.Select
    shapeExcel.TextFrame2.TextRange.Characters.Text = dblAACountWE2

    'Close and Save Workbook
    xlApp.ActiveWorkbook.Close (True)

    'Close Excel Object
    xlApp.Quit

    Set shapeExcel = Nothing
    Set sheetExcel = Nothing
    Set wb1 = Nothing
    Set xlApp = Nothing

    Thanks for your assistance!!

  10. #25
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    I am glad to hear that your business rules allow for this solution.

Page 2 of 2 FirstFirst 12
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Excel object, copy and paste a worksheet
    By crowegreg in forum Programming
    Replies: 2
    Last Post: 05-28-2014, 12:04 PM
  2. ActiveX failure to get Excel object
    By Monterey_Manzer in forum Access
    Replies: 3
    Last Post: 09-13-2013, 09:15 AM
  3. Displaying scrollbars in embedded Excel object
    By FelicianoRa@coned.com in forum Forms
    Replies: 1
    Last Post: 01-28-2013, 01:11 PM
  4. Replies: 3
    Last Post: 05-23-2012, 03:05 AM
  5. Replies: 8
    Last Post: 05-26-2011, 07:44 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