Answered by:
Open Photos via VBA

Question
-
In Access, via VBA, I want to open a photograph using Microsoft Photos. My environment is:
MS Windows 10,
MS Office 2013,
and VBA 7.1I have tried various techniques including the Shell Function and CreateObject; but without success.
My Shell() statement looks like the following:
Shell("C:\Program Files\WindowsApps\Microsoft.Windows.Photos_15.1026.13580.0_x64__8wekyb3d8bbw.exe")
I have tried various spellings of "Microsoft.Windows.Photos" but the results are always "File not found."
In Access, what is the best way to open Photos to show a particular photograph?
Friday, November 13, 2015 10:10 PM
Answers
-
In Access, what is the best way to open Photos to show a particular photograph?
Well, not necessarily the best way but you can use the following to open a file using whatever program is registered to handle it. For example:
Application.FollowHyperlink "C:\FolderName\FileName.ext"
or,
Application.FollowHyperlink "c:\MyPictures\MyPhoto.jpg"
There are other ways, of course.
Hope that helps...
- Proposed as answer by David_JunFeng Monday, November 16, 2015 5:18 AM
- Marked as answer by David_JunFeng Wednesday, November 25, 2015 1:58 PM
Saturday, November 14, 2015 1:19 AM -
adding on to the excellent help already given ...
if you use Application.FollowHyperlink and the default application to open the file is not the one you want to use:
.1. right-click on a JPG file in Windows Explorer or My Computer
.2. from the shortcut menu, choose: Open With > Choose another app
.3. Choose Windows Photo Viewer from the list
.4. check "Always use this app to open .jpg files"
.5. click OK
Then in the code, as the DB guy suggested, use Application.FollowHyperlink and then the filename or a reference to the filename.
If you are in the code behind the form with the path and file to the picture, this would be:
Application.FollowHyperlink me.ImageFile_controlname
WHERE
ImageFile_controlname is the Name property of the control containing the path and file to the image. This can also be a fieldname in the RecordSource
Warm Regards, Crystal http://www.AccessMVP.com/strive4peace * (: have an awesome day :)
- Edited by Crystal (strive4peace) MVPMVP Saturday, November 14, 2015 2:20 AM
- Proposed as answer by David_JunFeng Monday, November 16, 2015 5:18 AM
- Marked as answer by David_JunFeng Wednesday, November 25, 2015 1:58 PM
Saturday, November 14, 2015 2:16 AM
All replies
-
First, unless you're collecting the value returned by Shell, the parentheses are not required.
To use Shell, you must give it a valid path to the executable and, if applicable, the target file to load. I don't understand what you're talking about renaming the path several ways. There is only one way, the right way, verbatim...
I suggest that you open Windows Explorer and go to the Folder where your application resides. Place your cursor in the box at the top that displays the path. Select the contents, copy them to the clipboard, and then paste them into your statement.
Saturday, November 14, 2015 12:45 AM -
In Access, what is the best way to open Photos to show a particular photograph?
Well, not necessarily the best way but you can use the following to open a file using whatever program is registered to handle it. For example:
Application.FollowHyperlink "C:\FolderName\FileName.ext"
or,
Application.FollowHyperlink "c:\MyPictures\MyPhoto.jpg"
There are other ways, of course.
Hope that helps...
- Proposed as answer by David_JunFeng Monday, November 16, 2015 5:18 AM
- Marked as answer by David_JunFeng Wednesday, November 25, 2015 1:58 PM
Saturday, November 14, 2015 1:19 AM -
adding on to the excellent help already given ...
if you use Application.FollowHyperlink and the default application to open the file is not the one you want to use:
.1. right-click on a JPG file in Windows Explorer or My Computer
.2. from the shortcut menu, choose: Open With > Choose another app
.3. Choose Windows Photo Viewer from the list
.4. check "Always use this app to open .jpg files"
.5. click OK
Then in the code, as the DB guy suggested, use Application.FollowHyperlink and then the filename or a reference to the filename.
If you are in the code behind the form with the path and file to the picture, this would be:
Application.FollowHyperlink me.ImageFile_controlname
WHERE
ImageFile_controlname is the Name property of the control containing the path and file to the image. This can also be a fieldname in the RecordSource
Warm Regards, Crystal http://www.AccessMVP.com/strive4peace * (: have an awesome day :)
- Edited by Crystal (strive4peace) MVPMVP Saturday, November 14, 2015 2:20 AM
- Proposed as answer by David_JunFeng Monday, November 16, 2015 5:18 AM
- Marked as answer by David_JunFeng Wednesday, November 25, 2015 1:58 PM
Saturday, November 14, 2015 2:16 AM -
You might also like to take a look at BrowseDemo.zip in my public databases folder at:
https://onedrive.live.com/?cid=44CC60D7FEA42912&id=44CC60D7FEA42912!169
If you have difficulty opening the link copy its text (NB, not the link location) and paste it into your browser's address bar.
This little demo file illustrates how to browse to a file, assigning the path to a control in the form, and has options to view the file in its associated application, or to print the file. If the file type is not currently associated with an application it will prompt for the application in which the file is to be opened, giving you the option of associating all files of the type in question with the selected application. When opting to print an image file a dialogue will open, allowing you to select the format in which the image is to be printed.
Ken Sheridan, Stafford, England
Saturday, November 14, 2015 1:02 PM -
Thanks, this works as expected.Saturday, November 14, 2015 2:34 PM
-
Thanks, this works as expected.
Hi. Glad to hear you got it to work. Good luck with your project.Saturday, November 14, 2015 5:32 PM -
great! happy it is working for you ~
Warm Regards, Crystal http://www.AccessMVP.com/strive4peace * (: have an awesome day :)
Saturday, November 14, 2015 7:05 PM