Page 2 of 2 FirstFirst 12
Results 16 to 23 of 23
  1. #16
    DMT Dave is offline VIP
    Windows 10 Access 2016
    Join Date
    May 2018
    Posts
    1,371
    @ moke123, when you say standard module, do you mean within the same module as the sub ie: paste above the Private Sub or create a mod then call it ?

    I tried your post and comes back vriable not defined even with option explicit declared in the mod. that was pasted into Publuc Functions module, not the local module (above teh sub)

  2. #17
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,574
    even with option explicit declared
    That ensures variables need to be declared.

    What was the variable? Just Dim it.
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  3. #18
    moke123's Avatar
    moke123 is offline Me.Dirty=True
    Windows 11 Office 365
    Join Date
    Oct 2012
    Location
    Ma.
    Posts
    1,880
    Quote Originally Posted by DMT Dave View Post
    @ moke123, when you say standard module, do you mean within the same module as the sub ie: paste above the Private Sub or create a mod then call it ?

    I tried your post and comes back vriable not defined even with option explicit declared in the mod. that was pasted into Publuc Functions module, not the local module (above teh sub)
    Put it in it's own module or just import the module in the attached example.

    The three module types are
    Form Module ( a class module)
    Class Module ( a class module for custom classes)
    Standard Module

    As far as your error, my guess is that you didn't have the following part of the code at the top of the module:
    Code:
    #If Win64 Then      'Public Dclare PtrSafe Function
      Private Declare PtrSafe Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hWnd As Long, ByVal lpszOp As String, ByVal lpszFile As String, ByVal lpszParams As String, ByVal lpszDir As String, ByVal FsShowCmd As Long) As Long
      Private Declare PtrSafe Function GetDesktopWindow Lib "user32" () As Long
    #Else
      Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpszOp As String, ByVal lpszFile As String, ByVal lpszParams As String, ByVal lpszDir As String, ByVal FsShowCmd As Long) As Long
      Private Declare Function GetDesktopWindow Lib "user32" () As Long
    #End If
    
    
    
    
    Const SW_SHOWNORMAL = 1
    Const SE_ERR_FNF = 2&
    Const SE_ERR_PNF = 3&
    Const SE_ERR_ACCESSDENIED = 5&
    Const SE_ERR_OOM = 8&
    Const SE_ERR_DLLNOTFOUND = 32&
    Const SE_ERR_SHARE = 26&
    Const SE_ERR_ASSOCINCOMPLETE = 27&
    Const SE_ERR_DDETIMEOUT = 28&
    Const SE_ERR_DDEFAIL = 29&
    Const SE_ERR_DDEBUSY = 30&
    Const SE_ERR_NOASSOC = 31&
    Const ERROR_BAD_FORMAT = 11&
    Attached Files Attached Files
    If this helped, please click the star * at the bottom left and add to my reputation- Thanks

  4. #19
    DMT Dave is offline VIP
    Windows 10 Access 2016
    Join Date
    May 2018
    Posts
    1,371
    @moke123, yes, imported your modOpenApp and no problem, i had coped into an existing modiel where i have various functions set.

    once pulled in the modAopenApp, totally works a treat

    I have called it by path and file string

    Code:
        
    strPath = "T:\Databases\"strFile = "DMT Staff Holidays.accdb"
    
    
    OpenNativeApp strPath & strFile
    So this will open any/most file extensions ?

    also my occasional barain freeze in lacking of closing objects, there would never be a locked file after closing ?

    thank you all indeed

  5. #20
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,574
    Some people write code that when they open something, they immediately write the code to close it. Then they write the relevant code in between. I don't do it that way, but you might try that method?
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  6. #21
    DMT Dave is offline VIP
    Windows 10 Access 2016
    Join Date
    May 2018
    Posts
    1,371
    Pual, i think i am the minority in that group, always debug.print, the amount of times you have propmted me that, it pays off, mindest is now debug.print and stop, see the reeult then move to the next part

    you are all a great help to everyone, not just me..

    TY

  7. #22
    jojowhite's Avatar
    jojowhite is offline Competent Performer
    Windows 11 Access 2021
    Join Date
    Jan 2025
    Posts
    437
    without using API, you can accomplish the same:

    Code:
    strPath = "T:\Databases\"
    strFile = "DMT Staff Holidays.accdb"
    CreateObject("Shell.Application").NameSpace(0).ParseName(strPath & strFile).InvokeVerb "Open"

  8. #23
    DMT Dave is offline VIP
    Windows 10 Access 2016
    Join Date
    May 2018
    Posts
    1,371
    @jojowhite, WOW that is so efficient

    Just googled invokeverb, not come across that at all, don't have time for a short while to read it all through but, assuming invokeverb is to do with (( What Do You Want To Do With strPath & strFile )) "Open" in this instance ?

    TY

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

Similar Threads

  1. Replies: 3
    Last Post: 01-06-2022, 06:26 PM
  2. Replies: 2
    Last Post: 05-15-2016, 10:27 AM
  3. Replies: 8
    Last Post: 01-20-2015, 01:08 AM
  4. MS Access triggering Outlook Security warning
    By Amiga1200 in forum Programming
    Replies: 5
    Last Post: 05-22-2014, 11:24 PM
  5. Replies: 3
    Last Post: 11-20-2012, 01:40 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