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




VBA - How To Open Notepad


Does anyone know how to open notepad? I want to open notepad, make a new .txt file and SaveAs.




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
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!!!

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.

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"?

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

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

Have Notepad Open A File From My Program
I need to have my program open a txt file and disply it, but it is very very large. so I would like to have the win program word pad open it. :-)

either with in my program or externally is fine, It is just to view a couple thousand line log file.

Please help...


Sincerely,
Nick

Open Text File With Notepad??
I've tried to open the text file with notepad with the
following command


ShellExecute(Me.hwnd, "open", "c: emp
eadme.txt", 0&, 0&, SW_SHOWNORMAL)

but it wouldn't do anything, I'm pretty sure in the register, the txt file is associated with notepad

Any idea?

Thank you in advance for any help!!

Using Shell To Open Notepad With A File
Yo yo yo

I want to use shell to open notepad and then open a file within notepad
the only thing that I have is


Code:
Shell ("Notepad")


now I need to somehow use my app to open a file in notepad

any Ideas?? (Im using vb6)

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

(solved) Open Notepad Shell Problem
i cant get the following command to work.


VB Code:
openshell = Shell("notepad ", vbNormalFocus) & App.Path & "log.txt"

Printing To Notepad And Open With Results (Resolved)
I need a basic example to carry the results of a form to notepad and open notepad with the values passed.

If you could just give me an example of how to print "Hello World!" to Notepad and open Notepad after the value has been passed, then I think I can do the rest myself.

Your help will be appreciated.

Open Notepad And Display Text Which Isn't In A File
How can I open notepad and display text which isn't in a file?

My prog processes an input file to create some output text.

I have a button
"open in notepad"

I want it to open notepad with the text but with no file name, as though a "new " had been selected from the File menu.


Thanks

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.

Use Shell To Open Notepad With A Filepath That Is Not Hardcoded
Currently, I have a call to launch Notepad with a particular textfile.

Shell "Notepad C ProgramFiles est1.txt",vbNormalFocus

But I don't want the path to be hardcoded. How would I insert the variable into the code eventhough the quotes extend from Notepad to the end of the file string?

For example,
path=txtbox1.text

filepath would be path & " est1.txt"
Thank you.

Open Notepad To View Text File
Can anyone please give me the code to open an existing text file to view in Notepad? Thanks in advance.

Simple: VB Scipt In Notepad To Open An Excel Document.
I've never written any VB ouside of VBA for excel so i'm completely lost. It is a very simple procedure, but i know nothing of VB syntax. This will be my starting point. If i have a filepath and a filename, what is the correct script to open the document??? It is an excel file.

Thanks for your help.

jpc

Text File Opening In Notepad Want To Open In Winword
Anyone

I've created a file in note pad
basically i want to open that same file in winword
How do i do it ?

Open "s.txt" for input as #1
Do until EOF(1)
Line Input #1, TMP$
Loop
Tmp$ = Tmp$ + vbcrlf$
CLose #1

Regds
Sam F

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