Page 3 of 3 FirstFirst 123
Results 31 to 39 of 39
  1. #31
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,954

    Quote Originally Posted by sjlevine34 View Post
    Right now, the only App I use with an API call is the one that lists a database's properties and it is coded for both (#IF WIN64 Then...#Else...#End If).
    OK, good luck going forward

    Just for info, that conditional compilation syntax using #If Win64 isn't usually necessary/appropriate

    The following is an example of syntax will work on any version of Access whether 32-bit or 64-bit
    Code:
    #If VBA7 Then
       'add PtrSafe and use LongPtr for pointers/handles
        Private Declare PtrSafe Function FindWindowEx Lib "user32" Alias "FindWindowExA" _
            (ByVal hWnd1 As LongPtr, ByVal hWnd2 As LongPtr, ByVal lpsz1 As String, ByVal lpsz2 As String) As LongPtr
        Private Declare PtrSafe Function ShowWindow Lib "user32" (ByVal hWnd As LongPtr, ByVal nCmdShow As Long) As Long
    #Else
        Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" _
            (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
        Private Declare Function ShowWindow Lib "user32" (ByVal hWnd As Long, ByVal nCmdShow As Long) As Long
    #End If
    However if all users are running A2010 or later, all will have VBA7 so just the first section is needed without conditional syntax:

    Code:
    Private Declare PtrSafe Function FindWindowEx Lib "user32" Alias "FindWindowExA" _  
          (ByVal hWnd1 As LongPtr, ByVal hWnd2 As LongPtr, ByVal lpsz1 As String, ByVal lpsz2 As String) As LongPtr
        Private Declare PtrSafe Function ShowWindow Lib "user32" (ByVal hWnd As LongPtr, ByVal nCmdShow As Long) As Long
    Last edited by isladogs; 10-12-2020 at 08:09 AM.
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  2. #32
    sjlevine34's Avatar
    sjlevine34 is offline Advanced Beginner
    Windows 10 Office 365
    Join Date
    Sep 2020
    Posts
    39
    Thanks. It looks intriguing. I started to look at your link last night, so I probably will be following up with this in the future.

  3. #33
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,954
    Not sure whether you were replying to Micron or me. However Micron's link to Wayne Phillips site is very useful.

    I forgot to say earlier but I would make a further change to the file you uploaded in post #25.
    Your fOpenWorkbook procedure now uses CreateObject("ExcelApplication") but as written you will open a fresh copy of Excel each time even if already open.
    You can test that by repeatedly clicking your Open Excel file button and looking in the tasskbar.

    You prevent that by first testing for an open instance of Excel using GetObject(,"ExcelApplication") and using that if it exists. If it fails, CreateObject is then used.
    I gave an example of that code in post #21
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  4. #34
    sjlevine34's Avatar
    sjlevine34 is offline Advanced Beginner
    Windows 10 Office 365
    Join Date
    Sep 2020
    Posts
    39
    I was replying to you, but Micron and June7 have also been helpful.

    I was already cognizant of the create object creating a new excel instance each time. That is actually what I want. I release the instance by closing the spreadsheet. I was already aware of the GetObject call.

    Anyway, I have left the early binding in the original apps, since late binding does not seem to make a difference. I like early binding because it enable intelligsense and because it gives me the constants I need without having to redefine them.

    I actually noticed that the failure to take focus also occurs when I print a report to Adobe Acrobat as well, and that uses native access functionality, with my only code being to open report in print preview mode. This has actually begun only recently, within the last few weeks. I have played with the windows Focus Assist, turning everything off, but I have not rebooted so I do not know yet if it does anything.

    My two computers have different environments. One is a corporate computer with corporate security. The other is my personal computer with generic home security.

  5. #35
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,954
    OK so now I'm confused

    1. Which link were you referring to?
    2. If you create new Excel object every time, you will get the same issue with the flashing taskbar icon each time. Why would you want that?
    However by using GetObject, you will no longer get the issue after the first time you click the button.

    As for early/late binding. I develop use early binding to make use of intellisense, then swop to late binding once the app is ready for distribution
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  6. #36
    sjlevine34's Avatar
    sjlevine34 is offline Advanced Beginner
    Windows 10 Office 365
    Join Date
    Sep 2020
    Posts
    39
    I am not sure where I referred to a link in my last post.

    I did switch one of the apps back to creating an excel instance, using the Excel Reference Library, rather creating a new instance. It seems to work just the way I want it, only creating the single instance. I know its not kosher, but, what the heck.

    Your strategy of using early binding in development and late binding for distribution makes sense. However, I don't distribute my software anymore

    Again, thanks for your continued help.

  7. #37
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,954
    Hi again. Maybe we were at cross purposes.
    This was what I was referring to when I asked who you were replying to ...
    Quote Originally Posted by sjlevine34 View Post
    Thanks. It looks intriguing. I started to look at your link last night, so I probably will be following up with this in the future.
    Cheers.
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  8. #38
    sjlevine34's Avatar
    sjlevine34 is offline Advanced Beginner
    Windows 10 Office 365
    Join Date
    Sep 2020
    Posts
    39
    Isladogs

    Thanks for clearing up my confusion. It happens to us old men

    Be safe, all of you.

  9. #39
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,954
    Believe me, I know exactly what you mean ...!
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

Page 3 of 3 FirstFirst 123
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 6
    Last Post: 09-14-2017, 07:31 AM
  2. Replies: 34
    Last Post: 08-09-2017, 09:57 AM
  3. Replies: 5
    Last Post: 11-01-2016, 09:54 AM
  4. Replies: 2
    Last Post: 05-24-2016, 04:54 PM
  5. Replies: 1
    Last Post: 06-10-2012, 03:41 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