# Visual Basic > Visual Basic 6 and Earlier >  [RESOLVED] Opening a file with it's default program

## Darkbob

I've always used this to open a file with it's default program:

ShellExecute hWnd, "open", StrFile, vbNullString, vbNullString, SW_SHOWNORMAL

For some reason it's not working.

I have triple checked the file name and made certain the file opens and there's nothing odd about the file at all.

The file in question is a PDF.  I've double clicked on the PDF and it opens with Adobe Reader so the reader exists and it is set as the default.

The only thing that comes to mind... this is under Windows 11.  Could that be part of the weirdness?

Any help appreciated.  Thanks!

----------


## Elroy

Make sure you aren't using any strange compatibility settings on either the IDE or a VB6 compiled EXE.  These compatibility settings are known to break the ShellExecute API.

----------


## Darkbob

> Make sure you aren't using any strange compatibility settings on either the IDE or a VB6 compiled EXE.  These compatibility settings are known to break the ShellExecute API.


That must have been it.  I don't know what crazy stuff I've done to the IDE but that's where the problem is.  It doesn't work inside the IDE but once it's compiled, it works fine as an EXE.  Thanks for your help!

----------


## couttsj

On windows 11, this function has always worked for me:
RetVal = ShellExecute(0&, "open", TempPath & TempFile, 0, 0, 1)
The only thing different is I have not specified a Window.

J.A. Coutts

----------


## Elroy

> That must have been it.  I don't know what crazy stuff I've done to the IDE but that's where the problem is.  It doesn't work inside the IDE but once it's compiled, it works fine as an EXE.  Thanks for your help!


Just go find your VB6.exe (typically in C:\Program Files (x86)\Microsoft Visual Studio\VB98), right-click it, get the properties, go to "Compatibility" tab, and make sure nothing (but maybe Run As Administrator) is checked.  If you feel that you must have some compatibility, learn about shims and also read this thread.  The compatibility settings under properties break more things than they fix when talking about VB6 ... just don't use them.  Sure, a couple of shims do help, but not the full-blown compatibility settings.  And I've never used any shims or anything on a program compiled with VB6.

----------

