Page 2 of 2 FirstFirst 12
Results 16 to 19 of 19
  1. #16
    redbull's Avatar
    redbull is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Mar 2012
    Location
    Missouri
    Posts
    480
    So to build on this, You are running an access program, this program opens an excel spreadsheet... and that is the sheet we are wanting to close...



    The code bit we are fiddling with will give the PID of the current application that is being ran..... hmmm.... wow.... lemme think....

    How about... is it possible to save some vba behind the spreadsheet we are trying to close? I know we can call subs from one app to another...

    This is my code in a spreadsheet, that calls a sub in my access application.
    Code:
    Public Sub ProcedureInAccess()
    
    
    Dim acApp As Object
    Dim db As Object
    Set acApp = CreateObject("Access.Application")
    acApp.OpenCurrentDatabase ("C:\Program Files\LIFT\LIFT.mde")
    acApp.Visible = False
    Set db = acApp
    acApp.Run "CreateHTMLMail"
    acApp.Quit
    Set acApp = Nothing
    
    
    ' All macros designed and distributed by the LIFT team
    
    
    End Sub
    BUT if your access program is generating this spreadsheet from scratch, and not from a template... I don't know how to get the code behind it...
    Possibly creating an excel addon... (.xla) i think... That way you can run whatever macro or code behind ANY excel doc that is open... only problem being is the xla file would need to be loaded onto every users PC... Don't know if that would be an issue or not.

    ---------------

    To comment further and off topic... I like how these approaches are extensive, long and fairly complex... to do something as simple as shutdown excel... It's one of those things, that once you figure out how to do... is almost laughable...I had an issue with a checkbox in IE, I was trying to change its value.. I was stuck for days... then i finally figured it out.. and the response I received was, wow... a check mark in a checkbox...

  2. #17
    redbull's Avatar
    redbull is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Mar 2012
    Location
    Missouri
    Posts
    480
    Looking now

  3. #18
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    HOORAY, I figured it out:

    Code:
    Set xlApp = CreateObject("Excel.Application")
    
    With xlApp
    
        .Workbooks.Open sFileName, , True
        For i = 1 To .Worksheets.Count
            sSheetName = .Worksheets(i).Name
            DoCmd.TransferSpreadsheet acLink, acSpreadsheetTypeExcel9, "CurrentTab_Link", sFileName, True, sSheetName & "!"
            DoCmd.DeleteObject acTable, "CurrentTab_Link"
        Next i
        .Workbooks.Close
        '.Quit
    End With
    xlApp.Quit
    Set xlApp = Nothing

    I think what was happening is that it was opening the file as read/write and in the process of linking the tabs it was considering the file a modified file so I changed it to a read only opening and it worked like a charm.

    as you said it's always something simple and I couldn't believe it was going to be as complicated as getting a process ID and killing it that way.

    Huzzah for lunch breaks and mental reboots.

  4. #19
    redbull's Avatar
    redbull is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Mar 2012
    Location
    Missouri
    Posts
    480
    Amen, Yea I was looking into it and realized we were so far in the weeds we were ignoring the real issue. Well I am glad you figured it out, hopefully my commentary did not slow the process down.

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

Similar Threads

  1. Replies: 2
    Last Post: 02-14-2012, 04:40 PM
  2. Replies: 3
    Last Post: 10-07-2011, 07:49 AM
  3. Excel code not working with Excel open
    By jgelpi16 in forum Programming
    Replies: 1
    Last Post: 07-11-2011, 12:12 PM
  4. Export table to excel using excel template
    By allenjasonbrown@gmail.com in forum Programming
    Replies: 1
    Last Post: 06-27-2011, 02:10 AM
  5. VBA to open excel, import on close of excel
    By bdaniel in forum Programming
    Replies: 0
    Last Post: 03-20-2010, 02:45 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