Results 1 to 3 of 3
  1. #1
    3 Star Lounger
    Join Date
    Dec 2001
    Location
    Schenectady, New York, USA
    Posts
    273
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Focus on Form After opening Excel (2003)

    I am currently opening and Excel workbook from Access for the user to review and verify.

    What I want to happen is:
    1. <LI>User selects the file to open
      <LI>Open workbook
      <LI>User verifies.
      <LI>User closes workbook.
      <LI> Form now asks if the user wants to mark selected file as verified.
      <LI>User clicks Yes or No
    This is my code for opening the Excel file.
    Dim oApp As Object
    Dim oWbk As Object
    Dim PathFile As String

    PathFile = "xxxxxxdata01COMMON2ASPartnerTestParterFiles" & Me.lstFiles.Column(1, Me.lstFiles.ListIndex)
    Set oApp = CreateObject("Excel.Application")
    Set oWbk = oApp.Workbooks.Open(PathFile)
    oApp.Visible = True
    On Error Resume Next
    oApp.UserControl = True
    VerifyMsg = True

    On return (Got Focus)
    Dim resp As VbMsgBoxResult
    Dim strSQL As String

    If VerifyMsg = True Then
    resp = SndMsg("EmailVerify0001", vbYesNo, Me.lstFiles.Column(1, Me.lstFiles.ListIndex))
    If resp = vbYes Then
    strSQL = "UPDATE tbl_SentMail_Log SET tbl_SentMail_Log.MailFileVerified = True " _
    & "WHERE (((tbl_SentMail_Log.MailId) = " & Me.lstFiles.Column(0, Me.lstFiles.ListIndex) & "));"
    CurrentDb.Execute strSQL
    Me.lstFiles.Requery
    End If
    End If
    VerifyMsg = False


    I need to know how to lose the focus after I open the Excel File (#4) and then give it back to the form after the user is done (#5) with the file so I can ask if the file is correct.


    Thank you
    Don
    <img src=/S/flags/USA.gif border=0 alt=USA width=30 height=18> <img src=/S/flags/NewYork.gif border=0 alt=NewYork width=30 height=18> "Life on Earth is expensive, but at least it includes a free trip around the Sun."

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Focus on Form After opening Excel (2003)

    Simply put up the message box immediately after opening the workbook. The user won't see the message box until (s)he returns from Excel.

  3. #3
    3 Star Lounger
    Join Date
    Dec 2001
    Location
    Schenectady, New York, USA
    Posts
    273
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Focus on Form After opening Excel (2003)

    Thanks Hans

    That sure works the way I want it to.
    Don
    <img src=/S/flags/USA.gif border=0 alt=USA width=30 height=18> <img src=/S/flags/NewYork.gif border=0 alt=NewYork width=30 height=18> "Life on Earth is expensive, but at least it includes a free trip around the Sun."

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •