Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Launching NotePad App... how?

Posted on 1998-10-25
11
Medium Priority
?
290 Views
Last Modified: 2010-08-05
Hi,
  I would like to ask how do I launch NotePad application and automatically open , say "test.txt" from my VB program?
I don't have any Win API reference so I hope u guys can help me out.. thanks!
A simple eample would be very useful.. :)
0
Comment
Question by:Haho2
[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
  • 7
  • 2
  • 2
11 Comments
 
LVL 7

Expert Comment

by:kamall
ID: 1441495
Use the ShellExecute API function.
I will post you the code in a comment.
Regards
0
 
LVL 7

Expert Comment

by:kamall
ID: 1441496
Put the following declaration in a module (.BAS):

    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


Call the function from your form after specifying the full path/name of the .txt file:

    RetVal = ShellExecute(0&, 0&, FileName, vbNullString, vbNullString, WindowState)


The WindowState is:
 1 = Normal
 2 = Minimized
 3 = maximized

Regards
0
 

Author Comment

by:Haho2
ID: 1441497
thanks kamall
  but I was thinking of doing it by creating it as a wordpad/notepad object and then opening it. Can anybody tell me how to do it?
the reason is that it seems more professional?! Thanks again, kamall

 

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 1

Accepted Solution

by:
danielmarkus earned 80 total points
ID: 1441498
You can't use a notepad object, since it is not an activeX object. It is simply an executable object. You have to recreate notepad. Fortunately this can be done with a simple textbox with the multiline property set to true. Than you need to add some code.

There is already a very nice sample of this. It is in the samples directory of your vb directory. If everything is installed in the standard way it should be in:
C:\Program Files\DevStudio\VB\samples\PGuide\SDI
The program is called SDI and it contains a very nice implementation of notepad.

Good luck

Daniel
0
 
LVL 7

Expert Comment

by:kamall
ID: 1441499
danielmarkus,
You could have posted your answer as a comment.

Haho2,
Simply, it is not possible because the notepad is a normal EXE.
Please reject the current answer to enable me to relcok the question and get the points. Thanks.

Regards to all.
0
 
LVL 1

Expert Comment

by:danielmarkus
ID: 1441500
Look all,

It is not about the lousy points. Looking at this discussion I see a vague question with a clear and correct, however rejected answer, because the asker, wanted something else. Than I gave an other answer, which is defnitely correct.
Don't you going to tell me, Kamal, how I should post my answers. Bother someone else please.
Further I don't care about this nuisance and petty newby bull that you're exchanging. But comments like yours are the lowest I've come across so far in my online life. I hope you choke in your 40 points.

Good bye,

Daniel
0
 
LVL 7

Expert Comment

by:kamall
ID: 1441501
It seems that I stepped on your tail Mr. Daniel!
Since you know that my answer was clear and correct, why did you post an answer rather than posting a comment?
And finally, what was the 'lowest...' in my comment?
Be more polite here and respect others or better do not re-enter here at all because you will hear 'much much lower' comments than mine.

Haho2, sorry for the comment, but I had to respond to 'Mr. Daniel' for his impolite words.
Regards
0
 

Author Comment

by:Haho2
ID: 1441502
Thanks to both of you...
I appreciate that you both have given me the answer and other comments but I really don't see the need to "fight" over who gets the points.. after all, 40 is not that many points..
thanks again ...
0
 
LVL 7

Expert Comment

by:kamall
ID: 1441503
Haho2,
The issue is not really the points, but rather it is the way an 'expert' should react when he see an answer that is correct but was rerjected because probably the question was not so clear. In such cases, experts always submit a comment showing that the rejected answer was really correct and we give our openions and suggestions. That is the reason why danielmarkus should have posted his answer as a comment.
Anyway,
If you like to grade him, its up to you to decide. If you don't grade his answer and leave it, he will be graded automatically by the system after some it and you will lose the points.
So you have the following options:
Either reject his answer and refund your points, or
leave it as is and he will be graded automatically, or
if you would like to grade me, you should reject the current answer and leave me a comment.

Best regards
0
 
LVL 7

Expert Comment

by:kamall
ID: 1441504
Haho2,
The issue is not really the points, but rather it is the way an 'expert' should react when he see an answer that is correct but was rerjected because probably the question was not so clear. In such cases, experts always submit a comment showing that the rejected answer was really correct and we give our openions and suggestions. That is the reason why danielmarkus should have posted his answer as a comment.
Anyway,
If you like to grade him, its up to you to decide. If you don't grade his answer and leave it, he will be graded automatically by the system after some time and you will lose the points.
So you have the following options:
Either reject his answer and refund your points, or
leave it as is and he will be graded automatically, or
if you would like to grade me, you should reject the current answer and leave me a comment.

Best regards
0
 
LVL 7

Expert Comment

by:kamall
ID: 1441505
Oops, sent twice.... sorry.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
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…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses

610 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