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\sys tem32\mspaint.e xe" & "filepath"
End Sub
Many thanks for your help :)
4 9094
At first glance, I see two main problems in this line of code...
If paint = True Then Shell "C:\WINDOWS\sys tem32\mspaint.e xe" & "filepath"
First, you have not left a space after "mspaint.ex e". 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...
At first glance, I see two main problems in this line of code...
First, you have not left a space after "mspaint.ex e". Try that at the DOS prompt and see what happens.
I tried leaving a space after "mspaint.ex e" 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]
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?
...
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.
Sign in to post your reply or Sign up for a free account.
Similar topics |
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 message "NON EMPTY" if it is not empty.
(2) What are the steps to open a notepad file (C:\XYZ\abc.txt) in a VB Text
Box.
Thanks
|
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 System.Windows.Forms.DataGridBoolColumn
Protected Overloads Overrides Sub Paint(ByVal g As Graphics, ByVal
bounds As Rectangle, ByVal As CurrencyManager, ByVal rowNum
As Integer, ByVal backBrush As Brush, ByVal foreBrush As Brush, ByVal
alignToRight As Boolean)
|
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 works fine, it seems to fire
when the form changes visibility. Here is the code.
Private Sub lblP1JoyUp_Paint(ByVal sender As Object, ByVal e As
System.Windows.Forms.PaintEventArgs) Handles lblP1JoyUp.Paint
If lblP1JoyUp.Visible = True Then
Dim...
|
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 dilog Box.
|
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 Address:=filepath, NewWindow:=True
I don't want to read/write the file, nor to display FileDialog, I just want
to open a named file it in its own application (usually Adobe.pdf).
In Visual Studio 2005 I can successfully find the file using wildcards in:
...
| |
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 to be working ok. I
just don't know what I'm doing when I try to open a space delimited
file and want to put the data into columns. I tried recording a macro
in VBA and going from there, but then I got stuff saying "Name
'xlDelimited' is not...
|
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 graph area to
the clip board (easy enough using Me.OleGraphControl.ChartArea.Copy).
Next open an instance of MS Paint, paste the clipboard into the file and
save as something like "Picture.bmp" in the same directory as the FE
Access app. A...
|
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 the activesheet and copy/paste enter values in cells etc, but how
do I open a file and load the spreadsheet
|
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 username windows. My problem is now opening the Setup.exe from the program. I have tried using a OLE control and linking it with the file, but when it runs it comes up telling me "Out Of Memory".
If anyone can help please can you tell me if it is...
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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,...
| |
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...
|
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...
|
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,...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |