473,799 Members | 3,137 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to execute mspaint and open a file

19 New Member
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:\windo ws\system32\msp aint.exe", vbMaximizedFocu s)
Sep 22 '08 #1
8 19514
aas4mis
97 New Member
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:\windo ws\system32\msp aint.exe", vbMaximizedFocu s)
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 Recognized Expert Contributor
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
cobolguy
19 New Member
Appreciate the quick response. Still did not work. Paint comes up - but no image. Here is what I keyed:

Dim retVal
retVal = Shell("c:\windo ws\system32\msp aint.exe c:\CoronerDrawi ng.jpg", vbMaximizedFocu s)

I made the path simple and can double click this file and it comes right up in Paint.
Sep 22 '08 #4
cobolguy
19 New Member
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:\CoronerDraw ing.jpg"

retVal = Shell("c:\windo ws\system32\msp aint.exe " & """" & strImgPath & _
"""", vbMaximizedFocu s)
'
Sep 22 '08 #5
Megalog
378 Recognized Expert Contributor
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
cobolguy
19 New Member
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 Recognized Expert Specialist
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
gardoglee
1 New Member
"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
3660
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 these menus are then placed into the page by calling Server.Execute(rs_Modules("ModulePath")). This works fine for up to 15 "menus" After that, the session variables that were set (not including those called by Global.ASA) are no longer set. ...
3
9805
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 in a slightly modifies character set and contain commands only usable by the Server's SQL utilities. If one tries to use them on a machine which does not have the SQL utilities installed, one seems to have a laborious cut-and-paste task. (Of...
3
6166
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 info.ShellExecute = false; Process p1 = ProcessStart(info); Problem arises on complicated pathnames. If the string returned in info.Arguments is in say c:\pics\pic1.bmp then it loads fine. Only when
0
1163
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. When the user saves it I need to (behind the scenes) save the picture file and the location of the picture file. I'm going to put the location of the picture in a database for the user to call up later.
15
2826
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 was typed one after the other in a interactive session?
17
7150
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 Server.Execute. I found I can pass data TO the called asp file by creating an HTML <input> and erading it after I get there. However, I also need to read back ONE variable that the called file must set. I cannot figuer out how to do that. My...
3
2429
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 START and typed in the command myself.
0
1425
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 opens up and soon I got 20 copies of PAINT all open at the same time. When I do this with sound files, they all open in winamp (I think) and each one opens in the same copy of winamp, so no problem.
7
3537
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 file content of a php file (php code and html code mixed..) - execute the content with some zend api function I've already tried with zend_eval_string but not good because not
0
9546
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10490
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10260
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10243
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10030
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7570
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6809
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5590
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4146
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.