Solved

Opening image files in VB6

Posted on 2003-11-26
5
1,622 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Enroll in May's Course of the Month

May’s Course of the Month is now available! Experts Exchange’s Premium Members and Team Accounts have access to a complimentary course each month as part of their membership—an extra way to increase training and boost professional development.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

732 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