10 Years
Discussion Span
Last Post by mhine.jhuniane

there are some errors. it says shellexecute hWnd and SW_SHOWNORMAL are not declared.


hi, am brand new to VB. i have the same problem. i want to open a folder, say; My Computer on clicking a command button on VB GUI. i have something like this:

Private Sub Command1_Click()
ShellExecute hWnd, "open", "C:\apache", _
vbNullString, vbNullString, SW_SHOWNORMAL
End Sub
but it gives compilation error. "Sub or Function not defined"
can somebody help me out.


Private Sub Command1_Click()
Shell "explorer.exe C:", vbMaximizedFocus
End Sub

If you want to open some other folder instead of "C:" just delete "C:" and write the path to the folder you want to open.

Hope it helps

here other ways to open msoffice for additional information just edit the path

Dim Word
Set Word = CreateObject("Word.Application")
Set doc = Word.documents.Add(App.path & "\DOCUCAI.doc")
Word.Visible = True


'Dim dTaskID As Double, path As String, file As String
path = "C:\WINDOWS\notepad.exe"
file = App.path & "\USERMANUAL.txt"
dTaskID = Shell(path + " " + file, vbNormalFocus)


Set power = CreateObject("PowerPoint.application")
power.Visible = True
Set doc = power.Presentations.Open(App.path & "\Ppoint.ppt")
End Sub

all off those code will open msoffice files on the same folder where you save the put ur project..

good day

give me a feed back if it solve ur prob


thanx alot Hawisme000, it worked :)
i hope u will help me in future queries too ...


no prob Asad_ :) glad to help

im just returning the favor for this site~~~~~~~~~(singing) :D


say thats awesome! but how to open a folder on your own folder like no C: Drive? like opening folder sound? Please Help me!

Edited by jamesdeamon18: n/a


Private Sub Command1_Click()
Shell "explorer.exe C:", vbMaximizedFocus
End Sub

thanks for the code...im actually looking for this for the submission of my thesis thru cd

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.