Login | Register   
RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.

Tip of the Day
Language: Visual Basic Classic (6 and earlier)
Expertise: Advanced
Jun 30, 2009



Application Security Testing: An Integral Part of DevOps

Open Any File from Code

Using the following code snippet you can run any application (such as Word, Excel, etc.) or open any file whose extension is associated with an application, such as .doc, .txt, or other data files.

First, declare this Windows API function at module level:

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

Then, in your code, add the following line when you need to open a file:

lRet = ShellExecute(Application.hwnd, "Open", _
   "<Full path and filename here>", vbNullString, _
   "<Working directory here>", SW_SHOWNORMAL)

Substitute the path and filename of the file you want to run or open and the working directory for the target application for the portions of the preceding line shown in angle brackets.

Pavana Shireesha
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date