Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    Visual Basic




Making A Function Do An Action Such As Open Notepad


I am like totally new at this junk so please, don't laugh.
I'd like to make my program open the notepad or open anything really. Can someone help me figure out how? Thank you very much.




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Coding VB To Open File In Notepad Through API Function
I am trying to code VB to open file in Notepad through API function but It does not work.

Here are steps that I want in my VB code
1) Open Notepad
2) Open diaglog box
3) Enter file name
4) Click Open button ......That all

I need to code through API (not use "sendkeys" to send shortcut which I can do)

The following is code that I try to write

'Option Explicit
Private Declare Function FindWindow Lib "User32" Alias "FindWindowA" _
(ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function GetMenu Lib "User32" (ByVal hWnd As Long) As Long
Private Declare Function GetMenuItemID Lib "User32" (ByVal hMenu As Long, ByVal _
nPos As Long) As Long
Private Declare Function GetSubMenu Lib "User32" (ByVal hMenu As Long, ByVal _
nPos As Long) As Long
Private Declare Function SendMessageA Lib "User32" (ByVal hWnd As Long, ByVal _
wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Declare Function FindWindowEx Lib "User32" Alias "FindWindowExA" _
(ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal _
lpsz2 As String) As Long

Const WM_COMMAND = &H111
Const WM_SETTEXT = &HC

Private Sub CommandButton1_Click()
Dim hWnd As Long
Dim hMainMenu As Long
Dim hMenu As Long
Dim MenuID As Long
App = Shell("c:windowssystem32
otepad.exe", vbNormalFocus)
hWnd = FindWindow("notepad", "Untitled - Notepad")
If hWnd = 0 Then Exit Sub
hMainMenu = GetMenu(hWnd) ' get main menu handle
hMenu = GetSubMenu(hMainMenu, 0) ' first submenu (File)
MenuID = GetMenuItemID(hMenu, 1) ' 2nd item (Open)
X& = SendMessageA(hWnd, WM_COMMAND, MenuID, ByVal 0&) ' The program stop here to recieve command through dialog box that I don't want
OhWnd = FindWindow(vbNullString, "OPEN")
bOWnd = FindWindowEx(OhWnd, 0&, "Edit", "*.txt")
Y& = SendMessageA(bOWnd, WM_SETTEXT, ByVal 0&, "c:apitest.txt")
End Sub

Hope all of you can solve for me
Thank you very much

Is Any Api Function To Open Text File In The Already Launched Notepad.
Hi,

Is there any api function to open the 'c:abc.txt' text file in the already launched 'Notepad.exe' application.
Please give ur technical solution straitaway.

Note: without using the sendkeys() function.


Advance thanks
Adesh.
adesh@kmap.biz,adesh_y@yahoo.com

Copy All Text From Textbox, Open Notepad, And Automatically Paste To New Notepad Shee
Hello everyone.

I am trying to copy all text, that is already in the textbox, to a new notepad sheet.

Example:

Step 1. Copy all text in Text1 box to clipboard.
Step 2. Open Notepad
Step 3. Paste clipboard to notepad.

All this should be done with one click of a button.

I get as far as copying everything to the clipboard, and it even opens up notepad, but I still have to manually paste (CTRL-V) into notepad.

I would even like it to ask me what name to save it as as well as where to save it at...just like the Save As function in Word or something.

Here is what I have so far.

Private Sub cmdCopytoClipboard_Click()
Dim MyAppID
Clipboard.Clear
Clipboard.SetText Text1.Text
MyAppID = Shell("NOTEPAD.EXE", 1)
AppActivate MyAppID
MyAppID = Clipboard.GetText()


End Sub

Open Dialog To Open Text File With Notepad?
Hello,
Can someone please help me to open a text file with the Common Dialog control? I have seen your tutorial and it makes sense, but it uses a rtb control instead of opening the file with notepad as i would like.

HERE IS CURRENT CODE:

(Other properties were setup in properties pages)

Private Sub Command1_Click()
cdlOpenFile.Filter = "Text File (*.txt)|*.txt|All Files|*.*"
cdlOpenFile.ShowOpen

End Sub

THANKS!!!

Making Notepad
Hi there,

i m just a bit confused, do i use a normal form to make notepad like application or should i use mdi form since if i use mdi i will b able to create mdi interface. but if i use mdi form as parent & normal form as child then i am not able to create it very similar to word, which opens rich text box as soon as it is open whereas mdi doesnot allow to add rich text box. please help

Thank you

Got Tips/links For Making Top-view Action Game?
Hey

I would like to make some top-view multiplayer game where you run around the map picking up guns and shooting the other players. Kinda like a top-view Unreal Tournament game. Got any tips/tutorial links for such project? I have no idea where/how to start on this, like for example how would I make a bullet travel correct... I know I can use Intersect for simple collision and DirectX7 for gfx part.
Any links/tips/help I gladly take!

Making 'Sections' In A Notepad File???
Hello,

I need to know how to get my app to read certain 'sections' of a notepad.txt file and put it in different parts of my app.

EXAMPLE of an email app:
Form1 has
txtTo.text (To email)
txtSubject.txt (Subject)
txtMsg (Email Message)


Now what I want my app to do is when the user clicks cmdSave it will save the text from the three Txt Boxes listed above and save all the text to a .txt File.

Then the user can click cmdLoad and load the email later.

I have it all figured out except I need to know how to save the text from all three text boxes to the .txt file and then I also need to know how to load the .txt file so that it puts the appropriate text back in the right txt boxes.

I have all the code figured out on how to save it from one txt box to the file and how to load it back to the txtbox but I need to know how to save them all at once and load them all again when teh user clicks load...

Here is the code I am using for cmdSave and cmdLoad.


VB Code:
Private Sub cmdSave_Click()    cdl.Filter = "Text File|*.txtl"    cdl.InitDir = "C:Documents and SettingsDaNnYDesktopEmails"    cdl.ShowSave    If Len(cdl.FileName) = 0 Then Exit SubClose    Open cdl.FileName For Binary As #1    Put #1, , txtMsg.Text    Close #1End Sub




VB Code:
Private Sub cmdLoad_Click()     Dim sFilenames()    As String    Dim I               As Integer        On Local Error GoTo Err_Cancel      With cmDialog        .FileName = ""        .CancelError = True        .Filter = "All Files (*.*)|*.*|Text Files (*.txt;)|*.txt;"        .FilterIndex = 1        .DialogTitle = "Select File Attachment(s)"        .MaxFileSize = &H7FFF        .flags = &H4 Or &H800 Or &H40000 Or &H200 Or &H80000        .ShowOpen        ' get the selected name(s)        sFilenames = Split(.FileName, vbNullChar)    End With     Dim xStr As StringOpen cmDialog.FileName For Binary As #1        xStr = space(LOF(1))        Get #1, , xStr        txtMsg.Text = xStr        Close #1 Err_Cancel:         End Sub


Please let me know any ideas!

Thank you and have a great day!
Stilekid007

Making A Chart From Notepad Data Numbers?
Hello there!

I have notepad file in "C:vb6". The data inside the .txt file is numbers.

Example:
TXT FILE:

05/26/05 (DATE)
107.00 (High)
105.50 (Low)

05/27/05 (DATE)
108.70 (High)
107.50 (Low)

What I need to do with this file and data is have it be imported to my program and then, what it will do is output the data into a chart. So I was thinking I could have it use the "Line" feature of VB6 to make the chart. So the first vertical line would be on the date 05/26/05 and the bottom of the line would be 105.50 and the top would be 107.00. Then the next line would be on 05/27/05 with the bottom of the line at 107.50 and the top 107.50.

So the High and Low would determine the size of the line.

It would also have numbers on the right side of the form (I would like these would be automatically determined by what the very lowest number is and the very highest number is on the chart.))

Then when the user moves his mouse over any given line it will show the High, Low, and Date at the bottom of the form. (I have attached an example of what I would like it to look like (Similar to it anyway))

Does anyone know how to pull this code off?

Thank you so much to all who help!

Stilekid007

Making Notepad Stye Text Program
Hey guys, Im trying to create a program with the same basic look of notepad which will have a rich text box that enables me to write a page of text, print it, and have it tell me which page I am on when there are more then 1 pages that have been written. I want it to be able to have naturally centred text. Ive been looking around and havent seen any tutorials on how to make text programs, if you could help me out I'd be VERY grateful. Thanks in advance guys!

How Do I Open A Notepad File ONLY If It Is Not Already Open?
I don't want it to be open more than once.

Thanks.

Form Open Do Action?
Hey.. I know it's possible, but I haven't the slightest clue how to do it.
I wanna make my program so when someone switches tasks to it (alt tabs to the program), it does an action (in my case, checks the clipboard text to see if there's a link in it). I've tried form_onfocus, but I have a textbox in there, so it automatically is set focus.. I've tried IT being onfocus, and nothing happens.

Any ideas?
 Thanks ^_^



Edited by - Esona on 10/23/2005 5:39:16 PM

ComboBox Action To Open A Form
I have a ComboBox listing the Months (January, February, March, etc...). For each month I have a separate form displaying a chart. For example, when a user selects January in the combobox... I want my January Form to open.

How do I code:

frmJanuary.Show when "January" is selected in the combobox?

Current Code:

cboMonth.AddItem txtJanuary.Text
cboMonth.AddItem txtFebruary.Text
cboMonth.AddItem txtMarch.Text
- and so on -

Thanks for any advice!!!

ComboBox Action To Open A Form
I have a ComboBox listing the Months (January, February, March, etc...). For each month I have a separate form displaying a chart. For example, when a user selects January in the combobox... I want my January Form to open.

How do I code:

frmJanuary.Show when "January" is selected in the combobox?

Current Code:

cboMonth.AddItem txtJanuary.Text
cboMonth.AddItem txtFebruary.Text
cboMonth.AddItem txtMarch.Text
- and so on -

Thanks for any advice!!!

Open Like Notepad
Hi!

If I open a file (eg. *.wav) using the methods used in some threads in this forum,
it only displays some lines.
But if I open the file in Notepad, it's much bigger!

How can I open ANY file COMPLETELY?

PS_For some reason, *.txt works, but not the other extensions...

Open Notepad
hello.. i need a code on how to open an existing file (*.txt) to be exact. i have my textbox which is the path of where the file is located.. thanks

Open Notepad!
I am using the Microsoft Internet Control (WebBrowser control) in a VB6 application. How do I open NotePad when a menu item is clicked?

Thanks,

Arpan

Open To Notepad
How can I open a text file directly to notepad using vb code???

thanks,
vbk

Open NotePad
Hello

This should be easy. What is the syntax to open a file with notepad?

something (NotePad,"c:MyFile.txt")


Anybody know? I've looked in the MSDN and have found nothing?

Thanks

-William

Open Notepad
Nothing fancy, I just want to open notepad visually. Is it something like:

Shell.exe "C:WinNT
otepad.exe"?

VBA - How To Open Notepad
Does anyone know how to open notepad? I want to open notepad, make a new .txt file and SaveAs.

Open File With A Notepad
I want to open a file with a notepad so how can i do that ? thanks

Code To Open Notepad?
Hey guys I have a txt file, and I can open it into a text box, but for this file I would like it so if a user clicked on a button, it would open the file up in notepad. Is there a way to do that? Thank you!

How To Open Notepad File
hello every one ..
how to open notepad file....

i'm using
shell (app.path &"
eademe.txt"),vbNormalNoFocus


it give some error ...
so please suggest me what can i do for this purpose ...

anuj

Detect If Notepad Is Open
Is there a way to determine if Windows Notepad is open? (using VB code of course)

Thanks

Open Notepad File
how do you make Visual Basic open a notepad file?

I need it to open new notepad file every time the command button is clicked.

Open Txt File Using Notepad
I know I have done this before but I want to shell a txt or doc file and open either Notepad (txt) or Word (doc). I can only seem to get the shell command to open the exe file by pointing to it, I thought that if a txt file was associated to notepad by using shell on my txt file Notepad would open automatically.

I know you guys probably have more interesting things to answer but I cannot seem to get past this problem

Thanks

Open File In Notepad
I have a listview and a dirlist control in my program and i wanna be able to open the selected file in the listview in notepad. i'm using this line to do this:

Shell ("c:windows
otepad.exe"), Dir1.path & "" & ListView1.SelectedItem.Text, "", App.path, 3


what's wrong???? or is there other way to do this????





thax

Open A Notepad With Shell???
i know it but i forgot. please what was it again?

shell ("C:
ote......?

How To Open Files Within Notepad
Hello people, i am hoping you can help me, how can i get my VB program to open files within notepad, i.e. a .CDF file to open within Notepad, i am aware of how to use the shell function to actually open notepad, however using this i cannot open normal files, only executables.

Please help

Many thanks

How To Open Notepad.exe Through SQL Command
Dear Friends,

By using sp_oacreate with filesystemobject I can write the values in notepad. But I want to open the notepad exe in through sql command.

It is possible give ur valuable guidance to me

with regards,
anas danie r a

Open A Notepad Program
i have using this coding....
Code:Public 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

Private Sub cmdExecute_Click()
ShellExecute hwnd, "open", "C:Documents and SettingsMaxDesktopvbpowervb powerJeffCal.txt", vbNullString, "C:", 1
enb sub
 

but the coding have some problem....
error message: Only comments may appear after end sub,end function or end property

Open A Notepad Program
i wish to open a notepad application that i have specified .....like C: est.txt....when i click on the command button...the notepad program will promt up and show the containe of the test.txt

Open A TXT File With Notepad
if I have a TEXT file..I want to open it by Notepad after clicked a button in VB..
how can I do so??
which control should I use?
Thank you

Open File In Notepad
I have a *.txt file listed in a List Box. What is the simplest method to open it in Notepad. Let's say double click on that file in a list box will opens this file.
Thank you.

Open File In Notepad
I would like to know how I can open a text file from vb using Notepad.If I using shell command it will be hard if the notepad.exe in other folder.

Thank You

Click Action To Open A Word Merged Document
Hello,

Here's the scenario.  Our company has developed a web-based application.  The user clicks on a record in a list to review the record details.  We want to have a printable copy appear at the click of a button.  The data underlying the printable report is stored in multiple tables within a SQL ODBC database.

We need a quick fix by Friday.  I've developed an MS Word merge document to handle the data.  I am also skilled in MS Access and Crystal Reports design.  Here's what I'm looking for:

1.  Have any ideas on how to handle this quickly?
2.  What is the code to open an MS WORD Merge document object upon a button click.
3.   If I used MS Access or Crystal Reports how would I open just the report with a click of the button?

Again, I have a tight time constraint.  Any suggestions are welcome!

--Sandy

Using VB To Save An Open Notepad File
Hi,

I was hoping someone might be able to help me with a quick question. I don't have any written code, sorry.

I used the macro recorder to try and save an open notepad file on my desktop but no code appeared in the vb module. Can this be done? I'm a little lost for ideas.
Any help would be greatly appreciated.

Thanks.

Open Notepad At A Line Number
I have a program that reads data in from a txt file, but first it reads the file to check for any inconsitancies, if one is found it doesn't execute the routine and tells them that there is an inconsitancy and what line number it is on. I then ask if they want to open notepad to view it. I was wondering if there is a way that I can get notepad to open with the cursor already on that line number. My thought was that there must be some sort of command line argument or switch.

Thanks for any help.


Derek

Open Notepad With Variable Title
Hi.

For a project im doing, im keep records of local garages. Every time i add a garage to the database a notepad document is created and saved with the garage id.

The user has the option to view these notepad documents. When the relevant button is clicked, an inputbox appears which will take the required garage id. Using this input, i want to be able to open the specific txt file which has the input for a title. This is my code atm:

Dim id1 As Integer
id1 = Val(InputBox("Enter Garage ID"))

If id1 = 0 Then
Else

Dim shell, fsco
Set shell = CreateObject("WScript.shell")
Set fsco = CreateObject("Scripting.FileSystemObject")
shell.run = """notepad"""
end if

can anyone tell me how i can open notepad using this variables value as a title. thanks

Open Acrobat Reader Or Notepad [VB6]
I need to code the following pseudo code in VB6; any help would be appreciated.

If Acrobat Reader is installed then open c: est.pdf
Else if Notepad is installed then open c: est.txt
Otherwise Message box, no application able to load information

Thanks,

Open Text File With Notepad
I would like to open a text file with notepad or wordpad. I tried the shell-function. But that doesnt work.

bool = Shell(notepad "hallo.txt")

It once worked but I forgot how...
Please help!

Anita

Open A Text File (in Notepad) From VB
Hello,

I want to open a specific text file from within VB. For example, by clicking a button. I have tried ShellExecute..but it does not seem to work.

Help.

Thanks!

Open Notepad With Variable File Name???
Hi
Im having yet another problem with using variable filenames. I want the user to be able to open a existing text file in notepad by clicking a button. The filename is stored as a string. Heres what im trying:

VB Code:
Private Function viewFile() If Right(appPath, 1) <> "" Then appPath = appPath & ""strPath = appPath & "moods" & songTitle & " mood.txt"Shell "notepad.exe" & strPath, vbNormalFocusEnd Function


However i get a file not found error. The file exists, (im not checking this at the moment but will do if i can get this working).

Is there a way to do this?

Thanks

How To Open External SW (like Notepad) Inside VB??
Hi

i have a frame on the form, and with a click on a button i would like to
open the notepad (or wordpad) INTO this frame.
i know how to open an external SW, but not to "merge" it in VB.

thanks

Open Text File In Notepad
My application generates a number of .Log files. All are standard text files that I can easily view in Notepad. What I'd like to do is add a menu item which, from within my program, my user to open them and view them, in notepad. I've tried:
VB Code:
Shell "c:myfoldermylog.log", vbNormalFocus'and I have triedShell "notepad.exe c:myfoldermylog.log", vbNormalFocus
And neither one works. What am I doing wrong?

Open Acrobat Reader Or Notepad [VB6]
I need to code the following pseudo code in VB6; any help would be appreciated.

If Acrobat Reader is installed then open c: est.pdf
Else if Notepad is installed then open c: est.txt
Otherwise Message box, no application able to load information

Thanks,

Open With Notepad To Last Line In File
IF possible can anyone tell me how to open a file with notepad so you are viewing the last line ?
I don't want to just slam a bunch of page down sendkeys at it...

I need a scrolling display of the progress of a bunch of macros in Excel. Since Excel Application.ScreenUpdating = False I can't just write the messages to a cell, and msgbox stops the proceedure, hence the notepad idea...Also I keep having to re-open notepad as It doesn't view the file in real time as written:

UIhandle = FindWindow(vbNullString, "UserInfo.txt - Notepad")
PostMessage UIhandle, WM_SYSCOMMAND, SC_CLOSE, 0&

Open "C:StockBookUserInfo.txt" For Append As #1
Print #1, MESSAGE & " " & Format(Now, "hh:mm dd/mmm/yy")
Close #1

Shell "Notepad.exe " & "C:StockBookUserInfo.txt", 3 'somehow to last line of file

Maybe someone has a whole different approach...Else how open notepad to last line in file ??

tkx folks

Open Notepad File Using App. Path
is it possible to open a specific file with windows notepad using App. Path in a Shell Statement?

this works
Shell "c:windows
otepad.exe c:aaworkvbToolswinapiJohnTest.txt", vbNormalFocus

this does not
Shell "c:windows
otepad.exe app.pathJohnTest.txt", vbNormalFocus

Open Notepad With Shell Command
The following works fine in my uncompiled program. But after compiling I get an error message that the About.txt can't be found. Is there a way of specifying the path:app with or without Shell to open the notepad file?
Code:
Shell "Notepad About.txt", 1


Stan

Copyright © 2005-08 www.BigResource.com, All rights reserved