Solved

Launching NotePad App... how?

Posted on 1998-10-25
11
279 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
Industry Leaders: 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!

 
LVL 1

Accepted Solution

by:
danielmarkus earned 40 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: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone 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…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

749 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