Solved

Opening image files in VB6

Posted on 2003-11-26
5
1,612 Views
Last Modified: 2010-04-17
I'm trying to write a program that will, at a click of a command button, open an image file in Imaging (Windows standard accessory).
0
Comment
Question by:walstadm
5 Comments
 
LVL 10

Assisted Solution

by:D_M_D
D_M_D earned 125 total points
ID: 9826920
Use the Shell ()

Try this example:

' open image in Imaging
Dim pathtoprogram, imagetoopen As String
pathtoprogram = "C:\Program Files\Windows NT\Accessories\ImageVue\wangimg.exe"
imagetoopen = "ImageName.bmp"
Shell pathtoprogram & imagetoopen, vbMaximizedFocus

--------
D_M_D
0
 

Author Comment

by:walstadm
ID: 9827044
I'm getting a file not found error when I add in the file name (and I know that the file is there and correct).
0
 
LVL 1

Expert Comment

by:suma_ds
ID: 9828973
try getting the program to certify the file exists befo u try to open it. an easy way to do this would be to use the open file dialog box.  (this would also eliminate tha possibility of an incorrectly spelt file path)

or have u already tried this?
0
 
LVL 9

Accepted Solution

by:
bhagyesht earned 125 total points
ID: 9829536
D_M_D is code is right just add a space after the wangimg.exe
modified code is as follows
(make sure the path is correct for the imaging software on my pc (win2k) its  at "C:\Program Files\Windows NT\Accessories\ImageVue\kodakimg.exe")


' open image in Imaging
Dim pathtoprogram, imagetoopen As String
pathtoprogram = "C:\Program Files\Windows NT\Accessories\ImageVue\kodakimg.exe "
imagetoopen = "ImageName.bmp"
Shell pathtoprogram & imagetoopen, vbMaximizedFocus
0
 
LVL 10

Expert Comment

by:D_M_D
ID: 9833935
Yeah, forgot the space...

That should do it.  

You can add a Common Dialog Control to your form and let the
user select the image like suma_ds said.

Add the Microsoft Common Dialog Control to the toolbox by right clicking on the tool box and choose components...  Then choose it from the list.  Add the control to your form along with a textbox and button.  The button code is below.

' Get image path
Private Sub Command1_Click()
CommonDialog1.ShowOpen
Text1.Text = CommonDialog1.FileName
End Sub

' Then just pass the Text1.Text value as the parameter.

pathtoprogram = "C:\Program Files\Windows NT\Accessories\ImageVue\wangimg.exe "
imagetoopen = Trim(Text1.Text)
Shell pathtoprogram & imagetoopen, vbMaximizedFocus

--------
D_M_D
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now