UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
 
   Reply to this topicStart new topic
> Determining Win 10 Default Apps, Access 2016    
 
   
cwfitz
post May 19 2020, 10:04 AM
Post#1



Posts: 143
Joined: 17-June 09
From: Georgia Coast (USA) Basically, I live in a swamp


Here's a poser for a real Access guru (not a critical issue, but a niggling problem):
Using Win10 and Access 2016 I have an app for a client that (at client's request) sends an external pdf document to the default printer. To wit, a list of docs (some Word, some XL, some pdf) appear as records in a continuous Access form on screen. The idea is, you select the record/doc, click a command button in the footer and the doc is printed. Absolutely no problem doing this with 'docx', 'doc', 'txt', 'xlsx'. But there is an issue with 'pdf'. I found a clever single line of code on a blog elsewhere using (Shell.Application….) that works wonderfully well - as long as some version of Adobe is the default Win10 app for 'pdf'. If the browser is the default app the line of code does nothing - no error; just nothing. I thought perhaps there may be a way in VBA to query the library of Win10 default apps. If Adobe version something-or-other was the default app then this neat single line of code would send the doc to the printer. Else, if a browser was the default app I'd send a message telling the user to first open the doc - then manually send to the printer. For reasons not discussed here I want to stay away from the Acrobat coding libraries in my references.
So, in short, is there a way in VBA to get a list of Win10 default software applications?
THX for your thoughts and ideas.
Go to the top of the page
 
DanielPineault
post May 19 2020, 11:38 AM
Post#2


UtterAccess VIP
Posts: 7,386
Joined: 30-June 11



Have you ever tried ShellExecute using the "Print" action?

https://www.devhut.net/2010/06/12/ms-access-vba-open-a-file/ (under the heading 'Custom Procedure Method')

--------------------
Daniel Pineault (2010-2020 Microsoft MVP, UA VIP, EE Distinguished Expert 2018)
Professional Help: https://www.cardaconsultants.com
Free MS Access Code, Tips, Tricks and Samples: https://www.devhut.net

* Design should never say "Look at me". It should always say "Look at this". -- David Craib
* A user interface is like a joke, if you have to explain it, it's not that good! -- Martin LeBlanc


All code samples, demonstration databases, links,... are provided 'AS IS' and are to be used at your own risk! Take the necessary steps to check, validate ...(you are responsible for your choices and actions)
Go to the top of the page
 
ADezii
post May 19 2020, 12:44 PM
Post#3



Posts: 3,089
Joined: 4-February 07
From: USA, Florida, Delray Beach


QUOTE
So, in short, is there a way in VBA to get a list of Win10 default software applications?

  1. It took a lot of trial & error, but you can retrieve a list of 'Registered Applications' on a Windows System which, would at least, point you in the right direction. This can be done by listing the Subkeys under the following Registry Path:
    CODE
    Computer\HKEY_LOCAL_MACHINE\SOFTWARE\RegisteredApplications
  2. On my PC using Windows 10, the output of the Code could reflect the attached Image.
  3. If you are interested let me know, and I'll see if I can create the Code for you.

This post has been edited by ADezii: May 19 2020, 12:44 PM
Attached File(s)
Attached File  Registry.JPG ( 104.71K )Number of downloads: 4
 
Go to the top of the page
 
DanielPineault
post May 20 2020, 06:55 AM
Post#4


UtterAccess VIP
Posts: 7,386
Joined: 30-June 11



You could refer to https://www.devhut.net/2012/07/10/vba-deter...en-application/ to see if the application is registered or not. That said, now that Windows 10 has Apps, they don't get installed or registered in the same manner, so you will not find a single location in the registry!

--------------------
Daniel Pineault (2010-2020 Microsoft MVP, UA VIP, EE Distinguished Expert 2018)
Professional Help: https://www.cardaconsultants.com
Free MS Access Code, Tips, Tricks and Samples: https://www.devhut.net

* Design should never say "Look at me". It should always say "Look at this". -- David Craib
* A user interface is like a joke, if you have to explain it, it's not that good! -- Martin LeBlanc


All code samples, demonstration databases, links,... are provided 'AS IS' and are to be used at your own risk! Take the necessary steps to check, validate ...(you are responsible for your choices and actions)
Go to the top of the page
 
ADezii
post May 20 2020, 07:40 AM
Post#5



Posts: 3,089
Joined: 4-February 07
From: USA, Florida, Delray Beach


QUOTE
works wonderfully well - as long as some version of Adobe is the default Win10 app for 'pdf'.

After some research, I do believe that I may have found the location in the System Registry (see Image) that shows the Default Applications associated with a File's Extension, but I am not really sure. The Image below depicts my Default (Default) Application for the .pdf Extension. I'm assuming that searching for a partial match on *Adobe* or *AcroExch* as a (Default) should do the trick, but again, not really sure. the logic does work on my PC. If the Poster wants to pursue this line, I'll write the Code then make the appropriate decisions accordingly.
This post has been edited by ADezii: May 20 2020, 07:42 AM
Attached File(s)
Attached File  Registry.JPG ( 48.98K )Number of downloads: 7
 
Go to the top of the page
 
cwfitz
post May 20 2020, 02:49 PM
Post#6



Posts: 143
Joined: 17-June 09
From: Georgia Coast (USA) Basically, I live in a swamp


Sir: I absolutely love your ExecuteFile() routine: clean, simple. And it works great (in my context) with Word Docs, Excel and even text files. However, and you may find this interesting, when 'Edge' is my Default App for PDF, ExecuteFile returns "File Not Found". However, when Acrobat Reader is the Default App for PDF, the ExecuteFile works just fine (note I used 'print' instead of 'open'). But thanks for sharing this with me. I love it.
Go to the top of the page
 
cwfitz
post May 20 2020, 03:03 PM
Post#7



Posts: 143
Joined: 17-June 09
From: Georgia Coast (USA) Basically, I live in a swamp


Very interesting. Thank you. I find it interesting that when I see your list of "Registered Applications", MS Edge made the list. On my similar list (same registry address) I don't show 'Edge' even though it's my default browser.
I also referenced the reg entry for 'classes\.pdf' and found that the (Default) value was 'AcroExch.Document' regardless of what "Default App" was selected for pdf docs.
Thanks for your offer to help me wade into this. But I respectfully decline. That's way out in the deep end of the pool and I'm not sure the results of your research would be worth the (as I see it) amount of time that would go into it. I'll live, coding-wise, with what I've got.
Go to the top of the page
 
ADezii
post May 20 2020, 03:52 PM
Post#8



Posts: 3,089
Joined: 4-February 07
From: USA, Florida, Delray Beach


Before you make your final decision, take a look at the Demo. If the Default Program for the *.pdf extension is Adobe Acrobat Reader, you are prompted to print it using you existing Code, if it is not Adobe than the User is advised to Open the File manually and Print it from the Server Application whatever it may be. I modified the Function to return an Empty String ("") if there is an Error notifying the User off same. Granted, the Code is a little complex, but it is transparent. You make the call on this one.
Attached File(s)
Attached File  Registry_II.zip ( 28.69K )Number of downloads: 1
 
Go to the top of the page
 
cwfitz
post May 21 2020, 03:38 PM
Post#9



Posts: 143
Joined: 17-June 09
From: Georgia Coast (USA) Basically, I live in a swamp


Wow! A lot of thought and work went into this solution. However, it still isn't working (in my environment) as I need for it to. I tried three different Default Apps for PDF (and checked them to make sure they loaded the docs properly): Acrobat Reader, MS Edge, and a third party PDF Converter Pro from Nuance Software. Regardless of what the default app was at the time, Registry II.mdb consistently returned 'AcroExch.Document'. But I still appreciate your attention to this issue.
Go to the top of the page
 


Custom Search


RSSSearch   Top   Lo-Fi    12th July 2020 - 04:48 AM