Solved

Launching NotePad App... how?

Posted on 1998-10-25
11
275 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
  • 7
  • 2
  • 2
11 Comments
 
LVL 7

Expert Comment

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

Expert Comment

by:kamall
Comment Utility
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
Comment Utility
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
 
LVL 1

Accepted Solution

by:
danielmarkus earned 40 total points
Comment Utility
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
Comment Utility
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 1

Expert Comment

by:danielmarkus
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Oops, sent twice.... sorry.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

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…
Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
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…

743 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now