Solved

Launching NotePad App... how?

Posted on 1998-10-25
11
276 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
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
 
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
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…
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…

932 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

17 Experts available now in Live!

Get 1:1 Help Now