473,395 Members | 1,941 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

How to execute mspaint and open a file

I can execute mspaint using VBA but I have not been successful trying to open a .jpg image file. This command works to execute mspaint but I do not know how to excute and bring up a file at the same time. I am using Access 2007.

Dim retVal
retVal = Shell("c:\windows\system32\mspaint.exe", vbMaximizedFocus)
Sep 22 '08 #1
8 19268
aas4mis
97
I can execute mspaint using VBA but I have not been successful trying to open a .jpg image file. This command works to execute mspaint but I do not know how to excute and bring up a file at the same time. I am using Access 2007.

Dim retVal
retVal = Shell("c:\windows\system32\mspaint.exe", vbMaximizedFocus)
All you need is the file location after your command.
Expand|Select|Wrap|Line Numbers
  1. Dim retVal
  2. retVal = Shell("c:\windows\system32\mspaint.exe c:\image.png", vbMaximizedFocus)
Sep 22 '08 #2
Megalog
378 Expert 256MB
Are you dynamically opening different files with paint, or are you just trying to open one exact jpg?
If the image isnt going to change, then you could code it in like shown above. But, if the path has any spaces in it you will need to put the entire filepath in quotes.

If you're going to dynamically pass the file path to it, then use the following:
Expand|Select|Wrap|Line Numbers
  1. Dim retVal
  2. Dim strImgPath As String
  3. retVal = Shell("c:\windows\system32\mspaint.exe " & """" & strImgPath & _
  4.     """", vbMaximizedFocus)
That will ensure the proper quotes are inserted around the filepath.
Sep 22 '08 #3
Appreciate the quick response. Still did not work. Paint comes up - but no image. Here is what I keyed:

Dim retVal
retVal = Shell("c:\windows\system32\mspaint.exe c:\CoronerDrawing.jpg", vbMaximizedFocus)

I made the path simple and can double click this file and it comes right up in Paint.
Sep 22 '08 #4
Sorry guys - you were right. To the head of the class. I forgot I had used a macro instead of an event procedure. I am a little embarssed about that.
Thanks. It worked.

Here is the final work.

Dim retVal
Dim strImgPath As String
'
strImgPath = "c:\CoronerDrawing.jpg"

retVal = Shell("c:\windows\system32\mspaint.exe " & """" & strImgPath & _
"""", vbMaximizedFocus)
'
Sep 22 '08 #5
Megalog
378 Expert 256MB
Glad to help!
And your database already sounds way more interesting than the ones I work on.. with coroner drawings, etc =)
Sep 22 '08 #6
I am writing a system for our Coroner. This is the first complete system I have done using Access and VBA. I am truly a Cobol guy :)
Sep 22 '08 #7
missinglinq
3,532 Expert 2GB
I am writing a system for our Coroner. This is the first complete system I have done using Access and VBA. I am truly a Cobol guy
Well, that's really appropriate! After all, Cobol really is a "dead" language!

Linq ;0)>

P.S. Sorry, but you just make it so darn easy to be cheesy!
Sep 22 '08 #8
"Whoo-hoo-hoo, look who knows so much. It just so happens that your friend here is only MOSTLY dead. There's a big difference between mostly dead and all dead. Mostly dead is slightly alive."
Miracle Max


@missinglinq
Mar 15 '17 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Phil Grimpo | last post by:
I have a very odd situation here. I have an administration page, where based on a users permissions, a recordset is called from the SQL server which has a list of paths to "Module Menus". Each of...
3
by: Lyle Fairfield | last post by:
MS-SQL Server utilities Enterprise Manager and Query Analyzer will model almost any MS-SQL object as a simple script file with a default ".sql" extension. But how to "run these files? They are...
3
by: Tam | last post by:
Having problems with this code. ProcessStartInfo info = new ProcessStartInfo(); info.FileName = ("mspaint.exe"); info.Arguments = image.getFileName; // returns full path and name...
0
by: Matt | last post by:
Good afternoon all, I have a VB.NET 2005 application that I'm looking to add some functionality to. The basic idea is to have a place where the user can create a little sketch and save it. ...
15
by: tmp123 | last post by:
Hello, Thanks for your time. We have very big files with python commands (more or less, 500000 commands each file). It is possible to execute them command by command, like if the commands...
17
by: =?Utf-8?B?SmltIFJvZGdlcnM=?= | last post by:
I am trying to replace a huge chunck of code that currently I incorporate with an #Include directive. The program rarely has to flow through that code, so I thought it would be better if I used...
3
by: MLH | last post by:
What's the best way to launch MSPAINT c:\image.bmp from a VBA procedure. Seeking the route with the least number of complications. Hopefully there will be no more complications than if I clicked...
0
by: jackbenimble999 | last post by:
Hello! I am trying to make my MSAccess work with jpg files. I use hyperlinks to the file and currently the file will open in Paint. But when I click for the next JPG, then a NEW copy of PAINT...
7
by: Service4PC | last post by:
Hi all, I've a problem... I'm writing an extension for php, and i need to execute a file php... but only the content of the file and not the file... Now I better explain: - the extension get the...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.