Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Open .jpg with a button click.

Posted on 2003-02-25
8
Medium Priority
?
202 Views
Last Modified: 2013-12-25
I have a "xyz.jpg" document on my desktop, which I want to open with a button click from VB. I have the path to the file. I have no clue how to start with. Could someone help me out.

Thanx.
0
Comment
Question by:raj27
[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
8 Comments
 
LVL 7

Expert Comment

by:fluglash
ID: 8017474
Shell(pathname, [windowstyle])
0
 

Author Comment

by:raj27
ID: 8017631
fluqlash,
Ur command starts the .exe file, not a particular jpeg file. The pathname in ur command would be the path to an EXE file. I want a jpeg picture to open with a command button click.
0
 
LVL 3

Accepted Solution

by:
Egore earned 80 total points
ID: 8020450
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
Private Const SW_SHOW = 5

Sub main()

    ShellExecute vbNull, "open" & Chr$(0), "xyz.jpg" & Chr$(0), vbNull, "c:\mydirectory\" & Chr$(0), SW_SHOW

End Sub
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 3

Expert Comment

by:Rem
ID: 8024127
fluglash was right though.
The shell command needs an exe, parameters and windowstyle
Something like:
    Shell "c:\winnt\notepad.exe c:\boot.ini", vbNormalFocus
works.
0
 
LVL 1

Expert Comment

by:xThorx
ID: 8024179
Don't forget when you use the shell command to give the dos based path (8.3) of the pic otherwise it won't open the file.
0
 
LVL 3

Expert Comment

by:Rem
ID: 8024233
Shell "C:\Program Files\Internet Explorer\iexplore.exe C:\Documents and Settings\MyFakeAccount\Desktop\my personal testfile for EE.htm", vbNormalFocus

This works OK for me xThorx
0
 
LVL 1

Expert Comment

by:xThorx
ID: 8024394
That's luck. Try to launch a word document with longpath, it will launch the word but not the document! So the real safe way to use shell is to use the smallpath to the files.
0
 
LVL 3

Expert Comment

by:Rem
ID: 8024481
I know xThorx, in fact Egore's suggestion is the best.
In all cases the use of Shel is a bit dangerous because asynchro, i.e. the shell command is executed whatever the calling programme does.

Ciao

Rem
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

704 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