473,405 Members | 2,287 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,405 software developers and data experts.

Opening a file in paint using VIsual Basic 6

4
Basically, i have a program that shows images and i want it to open the image currently selected with mspaint so they can edit it.

Currently i can open paint when the user clicks a button i have set out however i cannot get paint to open the file being viewed.

I get the error "File path not found" but i'm not sure why, i thought it would be as simple as adding the "filepath" variable onto it.

Here's the code i currently have:
--------------------------------------------------------

Option Explicit

Dim paint As String
Dim filepath As String
------------------------------------------------------
Private Sub cmdpaint_Click() 'Button to open paint'

paint = cmdpaint
filepath = File1.Path + "\" + File1.FileName 'File path of currently selected file'

If paint = True Then Shell "C:\WINDOWS\system32\mspaint.exe" & "filepath"

End Sub


Many thanks for your help :)
May 2 '07 #1
4 9007
Killer42
8,435 Expert 8TB
At first glance, I see two main problems in this line of code...
If paint = True Then Shell "C:\WINDOWS\system32\mspaint.exe" & "filepath"
First, you have not left a space after "mspaint.exe". Try that at the DOS prompt and see what happens.

Second, you are not passing the pathname/filename, you are simply passing the literal value "filepath". Unless your image is called "filepath" with no extension and resides in the current directory, this is unlikely to work. You almost certainly intended to use the variable name filepath there, not a literal.

Oh, and a minor point - you are assuming the Windows directory will always be the same. Hm...
May 2 '07 #2
Crisis
4
At first glance, I see two main problems in this line of code...
First, you have not left a space after "mspaint.exe". Try that at the DOS prompt and see what happens.
I tried leaving a space after "mspaint.exe" and nothing i get the error that filepath.bmp doesn't exsist, which bring me to your other point:

Second, you are not passing the pathname/filename, you are simply passing the literal value "filepath". Unless your image is called "filepath" with no extension and resides in the current directory, this is unlikely to work. You almost certainly intended to use the variable name filepath there, not a literal.
My intention was to store the file path of the currently selected image in the "filepath" variable and then call it, but i guess it's not that simple..

I also know that some people will not have a default windows installation but i'll address that issue in a forthcoming update.

Any ideas on how to rectify my problem?

Many thanks.

Oh, and a minor point - you are assuming the Windows directory will always be the same. Hm...[/quote]
May 2 '07 #3
Crisis
4
It didnt process my changes....but anyway..sorry for double post.

What i've decided is that do you know how to show the "open with" box that is shown when you execute a file windows doesnt recognise?

My plan is to create a button that will show the "Open Wit" dialogue box so the user has a choice over programs they have on their machine.

It also solves the default program installation problem.

Is the above possible?
May 2 '07 #4
Killer42
8,435 Expert 8TB
...
My intention was to store the file path of the currently selected image in the "filepath" variable and then call it, but i guess it's not that simple..
Actually, it is. The problem is that you have used the wrong syntax in that line. The quotes (") around filepath make that a literal value. So where you meant to pass the value which is stored in the variable called filepath, you have instead passed the string "filepath".

If you put back the space after .exe and remove the quotes around filepath, I think you may find that it works.

As for the "which program" dialog, I don't know. Probably what you would need to do is have some kind of installation procedure which associates your application with that file type. I don't know whether the packaging/deployment that is bundled with VB will do that. You might need to look into a third-party product for that.

Or you may be able to simply do it from your code. I believe we've had posts on TheScripts in the past which accessing the list of file types and associated applications. Try a bit of searching and see what you can find. Note, it will probably help if you include some variant of the word "enumerate" in the search.
May 3 '07 #5

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

Similar topics

21
by: Sender | last post by:
I have two questions: (1) I just want to check whether a .txt file is empty or not (without opening it). Like I click on a command button then it should give message EMPTY if is empty and show...
3
by: Mike Cooper | last post by:
I have been staring at the above error for over a week now! I have a an inherited data class looking like thus: Public Class DataGridBoolColumnInherit Inherits...
6
by: jcrouse | last post by:
I am rotating some text is some label controls. In the one place I use it it works fine. In the other place I use it I can't figure out the syntax. I don't really understand the event. Where it...
2
by: Pankajmani das | last post by:
Dear sir I am trying to open a word file using Visual Basic Commad. But I am failed. So, please guid me to open a perticular word or another file. Note: I know how to open a file using common...
3
by: df | last post by:
In the old days of Visual Basic for Applications, I successfully opened a file (of any file type: .dwg .pdf .doc etc) in its own application using: ActiveWorkbook.FollowHyperlink...
2
by: Jacob.Bruxer | last post by:
Hi everyone, I'm having trouble opening space delimited textfiles in Excel from Visual Basic.net. I'm able to control, open and modify Excel files from Visual Basic, so my Excel reference seems...
1
by: Tim Marshall | last post by:
In my not too successful attempts to get an OLE chart object (Graph 11.0) that has been manipulated on a form to be reproduced on a report, I am considering the following procedure. First copy the...
3
by: Pete Vickers | last post by:
Hi, I am using Excel as a com object in VB.Net - anyone know how I can open an xls file please. Research seems to give me Axspreadsheet1.Workbooks.Open() but that doesn't exist. I can use...
2
by: bean41 | last post by:
Hello, I am trying to create a program that asks that user to enter a user name and their password, which then allows them to install a setup file. I have programed up the password and...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: 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
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
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
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...

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.