Using Wordpad With VB Saved Text Files
I have a program in which I save TXT files using Write (VB 3.0). I then have users connect to Wordpad to avoid a lot of printer issues via a selection in my program which auto opens the file.
My problem is twofold. Wordpad doesn't save page attributes for formatting such as margins or orientation.
Second, I need to insert a Page Break character in my file with the Write command at certain points. How do I do this, and how will wordpad handle them?
Any ideas. Many thanks....
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Open A Word Doc With Wordpad And Save As A Text File
I have a Ton of Word docs that I need to open in Wordpad and then save as a .txt file. I have an app that parses the txt file and loads that data into a DB. If I open .doc file with word and save it as a .txt file it crashes the parser. If I do it with Wordpad it works fine.
I'm looking for a way to automate the process with VB. But, I'm having no luck trying to get wordpad to work with VB.
I've tried to shell wordpad with:
Shell "wordpad", vbNormalFocus
This gives me an error code 53 File not found.
Shell "C:Program FilesWindows NTAccessorieswordpad.exe", vbNormalFocus
This opens up a blank wordpad doc, But I can't find a way to programatically open the doc file and do the save.
Shell "C:Program FilesWindows NTAccessorieswordpad.exe " & App.Path & "Worddoc.doc", vbNormalFocus
This one opens wordpad but then wordpad gives the error:
Connot find this file
Pease verify that the correct path and file name are given."
The path is correct to the doc file.
Can Wordpad even be manipulated via code?
Saved Over Old Files
I accidently saved some vb forms with the same name as some other vb forms that I really need. Is there a way to undo the overwrite?
Combining Saved Files...
OK. I want to take several text files, and combine them into one file. I think that u can save the text from each file in a string that is assigned a variable in the file. How do I go about doing it though?
"**** the torpedoes, full speed ahead!!!"
Rewriting Saved Files
I have a common dialog control and I need to save using this but when I try to create a new file and and have the kill method it will say path not found. Is there some way to test if the file is being created, if so then don't kill then just write, then if the file exists then kill it and rewrite it?
Encrypting Saved Vb .txt Files
Im trying to make this program more secure-like.
I can save to .txt but there are other things i wanna do
What I wanna do-
-Encrypt all words in .txt file. Maybe some long code for this somewhere someone knows about... Such as encrypting SUCH to shsdjsuhksfjkl. WHATEVER!. I know this might make the .txt size bigger, doesn't matter.
-Make the attribute of the saved .txt file HIDDEN. So it's invisible, for the most part, of course it is very easy to find the file I just want it to be invisible anyway
But rather then doing these ^ Can I somehow save it TO the program? So the .exe will have the .txt INSIDE it. Is this even possible !??!
And rather then
Open "File.txt" For Output As #1
Can I make it so every time it opens it doesn't erase the file and save from over? Because Im trying to make like a database, without using a recource file. Ill learn how to do that later, now the easy things.
Maybe I can change Output to Input? No idea, ive seen codes with that...
Anyway, hope someone can help me out, I know i gotta alotta questions, but im just learning
Trouble Opening Saved Files
I am a college student working on a data logging application for use with an injection molding machine. I'm using vb6 and office 2003. Excel opens fine and i can see the cells loading with the data from the PLCs.
The only problem is, when i try to open the files later from excel nothing comes up. Not even a blank sheet. Is there any properties that would make the file hidden or invisible?
Encrypt/Decrypt Saved Files?
Being completely honest with everyone i am a grade 12 going to college next semester for computer programming analyst so im not a pro.
I would like to know if there is a way to encrypt the variables that are saved to file from VB and then how to decrypt them. it is very easy for anyone just to edit the file in notepad etc.
Thank You! Your help is much appreciated
Opening Files Saved As Days Of The Month:
I'm trying to log data into excel sheets named as days of the month.
I'm using the following code:
Dim XLApp, XLSheet, Recipe
Set XLApp = CreateObject("Excel.Application")
Set Recipe = XLApp.Workbooks.Open("C:History" & Day)
Set XLSheet = Recipe.ActiveSheet
XLApp.Application.Visible = True
This is not opening the sheet I have named 24.xls (today is the 24th)
Removing &" Marks From Saved Files
I currently save files from within VB like so:
Dim ABC as String
Dim FF as integer
FF = FreeFile()
ABC = "XYZ Any string here"
Open "C:SavedFile.txt" for Output as #FF
Write #FF, ABC
This is fine, but it saves the strings with "" marks at tne beginning and end of the string. For example, in our sample file for this code, the text in the file would be:
"XYZ Any string here"
This is fine usually but I need to load the values without " marks. I know I can remove them during input, but I seem to remember that you can avoid that by using a different work wather than write to output the file. I tried print but it left massive gaps between the values (in the text file).
Any headsup on the word/method that I need to write the file without it having " marks? I've got a feeling I figured this out before, and it was just a simple word, but I can't find the code.
Get An Outlook Email Saved At C:program Files
I have an email saved as a template for a mass emailing. I want to pull this up to use it. How would I do that. Any thoughts. I really need this code. I am working on an application for a non-profit org. I have no problem pulling up emails from MAPI folders, but I want to access folders outside of Outlook
Spacing Out Between Saved Text...
How can I add a space between lines in a text file when user is saving it?
cboHome.Text & " to "; txtVisitors.Text & ". "; txtScore.Text; " score."
So once user enters text into those it saves into a file but in 1 line. How can I make it so there is space between each line?
Why Text File Not Saved Occassionally
Hello. I use a richtextbox to document our services to our clients. The textbox is saved in textfile. It does not save may be once in a few hundred times that I hit Save. Usually I hit Save and exit, believing that the document is saved. When return to that document, the textbox is blank sometimes, or sometimes only a newly added portion of the document is not there. Keep in mind, this happens only once in a few hundred times of saving the file, or once or twice a year. Does that have to do with memory for some reason? or what? I don't see anything wrong with the code. Below is my code for loading and saving. Please review and give me any advice. Thank you.
Private Sub ShowText()
'This line is needed to load a textfile name and save the file.
Get MainFileNumber, CurrentRecordPosition, mRecord
LblChildName2.Caption = Trim(mRecord.FirstName) + " " + UCase(Trim(mRecord.LastName))
LblParents2.Caption = Trim(mRecord.Parents)
LblClass2.Caption = Trim(mRecord.Class) + " -- " + Trim(mRecord.Teacher)
LblPhone2.Caption = Trim(mRecord.Phone)
' FSLogFileName is declared as string in Module
FSLogFileName = WorkingFilePath & "" & Trim(mRecord.RecordID) & "-Servicelog.txt"
Dim FindFilename As String
FindFilename = Dir$(FSLogFileName)
If FindFilename = "" Then
' Createfile if file does not exist
RichTextBox1.Text = ""
' RichTextBox1.LoadFile FSLogFileName
Else ' If filename was found, read record
RichTextBox1.LoadFile FSLogFileName ' Format to load Richtext file
' Brings cursor to the end of text
If Len(Trim(RichTextBox1.Text)) > 300 Then
RichTextBox1.SelStart = Len(Trim(RichTextBox1.Text))
Private Sub Save()
FSLogFileName = WorkingFilePath & "" & Trim(mRecord.RecordID) & "-Servicelog.txt"
RichTextBox1.SaveFile FSLogFileName, rtfRTF ' Save file
Bold Text Moves To Saved Txt?
ok guys see if you can figer this one out
i save a file to whatever.doc but its not saveing the formatting to the new file the bold text impaticaler
i use a true text box and i select text and hit a butten to bold the text selected.
this code runs
Private Sub cmdhighlight_Click()
rtbMdcDisplay.SelBold = True
that makes the text bold then i save it to a .doc file
Private Sub Command1_Click()
On Error GoTo hell
Open Dir1.Path & "" & Text1.Text & ".doc" For Output As #1
Print #1, FrmTxtWindow.RtbFileVeiw.Text
valuelabel.Caption = Dir1.Path & "" & Text1.Text & ".doc"
FrmTxtWindow.Enabled = True
MsgBox Err.Description, vbCritical, Err.Number
but then i open the doc file in word and all the formatting is gone only thing right is each line is on the right line.
so this text
this is a test normal
this is a test bold
comes up in word as
this is a test normal
this is a test bold
i hope you understand what i mean.. please help
thanks in advance
How Can I Use A Specified Information Saved In A Text File?
I have a program that uses this code to write the info entered by the user in a text file:
Private Sub Command1_Click()
n = Text1.Text
a = Text2.Text
Open "h:RECORDS.txt" For Append As #7
Write #7, n, a
I am using this code to put the first field (na) of info of the text file in a combobox:
Private Sub Command2_Click()
Open "h:RECORDS.txt" For Input As #3
Do While Not EOF(3)
Input #3, na, ag
How can I make my program so it only goes to the next form (ex. form2) when the second field of info (ag) in the text file is entered in the second textbox (a)?
Saved Text File Not Centered
I have a rich text box that has centered text in it, and I save it, but when I open it up and put it back in the text box it is not centered, and when I print the text it is not centered. What is wrong?
Loading Saved Text From Resource
here's the deal, i have loaded icons and text into a resource file... i can get at the icons alright but i have no idea how to load the strings from it.
the string index is 101, if this helps. its to load it into a text box.
Any relitive answer is welcome
Reading Uncode Saved Text File
i have a text file saved in unicode format (i needed to use 3 different langs there). how do i read the file and display text.
i guess i'd need to show it in RichTextBox, but if i just use Line Input and do RichTextBox.text= , then it just shows me like if i'd open it in notepad...
so, what do i need to do
Changing The Saved Info In A Text File
Let's say for example, some info's been saved using this code:
Open "C:Textfile.txt" For Append As #3
Write #3, Text1, Text2, Combo1.text, List1.text
and the text file is something like:
"James", "16", "Green", "1990"
"Bob", "20", "Red", "1980"
How can change an specific info in the text file? (For example, the user enters "Bob" as his name in my program and changes "Red" to something else in a combobox. So i need the computer to find "Bob" in the text file and change "Red" to something the user enters in my program.)
If any more info is required, tell me and i will add.
Asap & thnk you
Multiple TextBox's Saved To Text File
Hi, Please help.
I am creating a form in VB6 that has three textbox's and a "save" commandBox.
I would like the save box to take the information in the three textbox's and place them in a text file (c: est.text [for discusion purposes]), then clear the fields ready for the next information. Then when save is clicked again it "adds" the information to the text already in the test.txt file.
Thanks in advance for any help that may be offered.
Need A Code That Alowes Entries In Text Boxes To Be Saved
I am very new to VB..
I'm hoping some of you might be able to help me make a code to apply in text boxes made in MS Word 2000..
I have made a document with several text boxes, and saved it as a web page.
When I open the document in IE, I can add text in the boxes, and print it out.
What I would like is to be able to save the webpage with the entered text still in the boxes...
When I save now, and reopen, the boxes are empty..
Checkbox State Saved To Sequential Text File
I need to save the state of some checkboxes to a sequential textfile. I am getting a type mismatch when I read the state back out of the file as a string(true or false) and try to assign it to the checkbox on my form. What type of Variable should I be using?
Here is what I'm trying.....
To get the state from the form:
dim FL as string
if checkFL.value then
Once ive read the file and retreived it as a string, to assign it back to the checkbox:
checkFL.value = FL$
- this statement gives me a type mismatch when run. How should this be done?
Much Thanks for the help......Larry
Contents Of Datacombo Box Not Saved While All Others Are Saved!
I have a form that has text boxes,datacombo's and date picker controls.when i try to save anew record,the contents of the datacombo boxes are not saved here's the code i use
!PROJCODE = Text1
!CLIENTname = DataCombo1
!contact = Text4
!PROJTITLE = Text2
!PROJSTAT = List1
!StartDate = DTPicker1
!EndDate = DTPicker2
!budgetedexp = Text9
!Leader = DataCombo2
!budgetedhrs = Text11
I would like to open a text file in wordpad during runtime but the location of wordpad.exe may change from system to system. Is there a way i can search for the exe prior to calling the shell command?
With This code ShellExecute 0, "Open", sFileName, 0, 0, 3
i can open a file using notepad, but if i want to use wordpad?
Can anyone help, pls?
Run Wordpad From A VB App
I have a small Vb application and I want to open Wordpad and transfer the text of a text box when you double click on it.
Can anybody please help?
Thanks a lot,
Wordpad In VB???
I'll start off with: WHY HAVE WE GOT YELLOW ICONS?! Why not multi colored one?! Grrrrrrrrrrrrr...Bad fishes...
Anyways, in VB you can create a word document using something along the lines of:
Dim Woof As Word.Application Set Woof = New Word.Application Woof.Visible = True
...you get the point. Anyways, is it possible to do this with Wordpad?
WordPad And VB
How do i get/set the text of a wordpad window i opened through OLE?
I want to open it and put some text in it... when its closed i want it to send the (changed) RTF-text back to my app, so that i cant save it in an other format (I do not want to use the RTF-Control)
Help With Wordpad Path
I am writing an app that uses wordpad to print an RTF file. I am using the registry to get the path for wordpad.
I am getting the following key: HKEY_LOCAL_MACHINE, "SOFTWAREMicrosoftWindowsCurrentVersionApp PathsWORDPAD.EXE"
The key returns the following:
The problem I am having is resolving the %ProgramFiles% part into the appropriate drive & path so I can start Wordpad. What am I missing? Thanks!
Wordpad Is Cool!!!!!
Is there any way that I could add the Tab utility that is found in WordPad (e.g.: the ruler on the top of the app window, w/ the ability to adjust the tabs and intents...etc.)
im basically trying to make a WordPad clone, xcept MDI and w/ add. tools. just for fun, cuz i know it has been done millions of times...(i see the freeware apps like it EVERYWHERE).
-"your mother was a hampster and your father smelled of elderberries."
MDI Application. WordPad Like
I need to create an MDI app like WordPad, but I'd like to use an OLE container instead of the standard rich text box.
The problem is that when the object inside the OLE container is created (using createembed()), the document will take the actual size of the container at that moment, and when I risize the container, the document keeps it's original size.
Can anyone helpme with this ?
Focus On Wordpad In App
I've made a program, where you have a mdi form, with 3 childs. Two childforms on the left of the screen (about one third of the width), and the third one on the right of the screen. In that right form, i want to have wordpad. I've done that like this:
Private lngParent As Long
Private lngStyle As Long
Public winhandle As Long
Private Sub Form_Load()
pid = Shell(gwordpadpath)
winhandle = FindWindowEx(0&, 0&, vbNullString, "Document - WordPad")
lngStyle = SetWindowLong(winhandle, GWL_STYLE, GetWindowLong(winhandle, GWL_STYLE) Or WS_CHILD)
SetParent winhandle, Me.hwnd
MoveWindow winhandle, 0, 0, frmEditor.ScaleWidth, frmEditor.ScaleHeight, True
ShowWindow winhandle, SW_SHOWMAXIMIZED
Private Sub Form_Resize()
MoveWindow winhandle, 0, 0, frmEditor.ScaleWidth, frmEditor.ScaleHeight, True
Private Sub form_Terminate()
Call SetParent(winhandle, lngParent)
The declarations of those API-calls are in the module.
I also have a button in one of the child windows in the left (for speech recognition), and when that is pressed, all the input should come in the wordpad window. So it should have focus, and a cursor should be blinking there.
I've tried lots of things, but for one reason I can not get the focus on that window, so the cursor is in there, without actually clicking there.
Can somebody please help me, or give some other suggestions to import wordpad, so it does work.
.udl Modify In Wordpad Using VB
I am trying to work with several MS Access Backends. I am using a Data Link (.udl) file and would like to be able to modify the backend location using VB and re-write the path to Notepad as you can edit a Data Link using notepad. This is the code I am using:
Private Sub cmdLinkNew_Click()
Dim myDB As ADODB.Connection
Dim myRS As ADODB.Recordset
Dim strCnn As String
Dim DLink As String
Dim DLink2 As String
Dim DLink3 As String
Set gblConnection = New ADODB.Connection
If Right(LFile.Path, 1) <> "" Then
NameOfFile = LFile.Path + "" + LFile.FileName
NameOfFile = LFile.Path + LFile.FileName
gblConnection = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + NameOfFile + ";Persist Security Info=False"
DLink = "[oledb]"
DLink2 = "; Everything after this line is an OLE DB initstring"
DLink3 = gblConnection
Open "C:NEP.udl" For Output As #1
Print #1, DLink
Print #1, DLink2
Print #1, DLink3
I am using a common dialog box to browse to the file I want to use and that is captured in the "NameOfFile".
Now, here is the problem...
After I run the code, the .udl file is updated. However, when it moved to the next procedure it gives me an error: "The File %1 is not a valid compound file".
I JUST DON'T UNDERSTAND WHY!!!!
Everything should work! When I open the .udl in notepad it is changed and teh syntex is correct. When I manually change the .udl in Notepad it works. So why won't it work when I have VB change it?
Thanks for any useful advice. This is driving me crazy!
I need to get this up and running by tuesday next week (8-10-04) So I would appreciate any prompt solutions
i started vb 1 month ago in my country using mastering visual basic book but i didnt find any good thing in it can u friends help me in making a word processor like windows word pad ? containing good options like microsoft word any version ?
if any one help i'll be thankfull to him always
Thanks in advance :P
Does anyone know if WordPad can only display a certain amount of info?
I've got a huge dat file that I need to seperate into smaller dat files in order for this preprocessor to be able to parse them without crashing, so I opened up this 139 mb dat file in word pad, copied and pasted sections of it into smaller files. Then wrote a quick program to count the lines in each to make sure they match the original. I'm getting totally different results, like the visible data I copied and pasted came out to 66 thousand lines, where as the original file comes out to over a million lines. Now, in looking at the contents of the variable where I input the data into, at line 1 million, it shows data that I cannot see in the word pad file.
Long story, sorry. So, I'm wondering if WordPad is only opening so much of the file without warning me that it cannot open the rest.
I have not tried programatically to break up the file, I guess that's next.
Just very curious if anyone knows of WordPad limitations in this area.
Whew, if you made it this far, thanks for reading.
Thanks in advance.
Possible To Manipulate Wordpad From VB App ?
I'm sure it is, I just need to find the right expert
I'm shelling Wordpad and loadnig a document (80 characters wide).
Unfortunatley Wordpads default left and right margin size makes the doc narrow than 80 characters wide, and it wraps my lines.
Manually I can adjust this in PageSetup, but what I need to do is automate this process.
Is this possible ? Do I use something like SendKeys to get the desired result ?
Has anyone else done anything similar ?
Do I have any more questions ? ............................ no.
Question: Can WordPad be used for object programming from VB like Word or Excel ?
Launch Wordpad From VB6 App
I need to add a feature to my app allowing the user to launch WordPad. I'd also like it to specify the target directory and "files of type" so that when the users do a file/open in WordPad they will be presented with only the files of specific type and in a specific directory.
I'm sure it can be done, but have no idea how.
Location Of WordPad
Is there somewhere that tells you the location of WordPad on your users harddrive? I want to load my log files into WordPad without having to change the person's file association.
Creating A New WordPad
Hi, I'm new in VB and my lecturer asked us to create a prototype of an improved program.
Question : How do we get the .doc file filter in wordpad to be integrated in our project? Thanks
How to manipulate wordpad ?
I don't want to use the shell + sendkeys statements
Is there another way to perform it ? like a createobject or whatever...
I have a 'Readme' text document that accompanies my app.
I want to open 'Readme' from Form Activate so that the text file opens in Notepad and is the first thing the user sees before using the app.
Assuming the file is Readme.txt and it is on app.path, how can I do this.
(I don't want to create a form with the info on it)
The code would be much appreciated
Wordpad Document In Vb
Here is my problem,hope someone will get to it:
I have this app where i need to allow the user to write information about some items in a database, to format some text (bold chars,tabs,font colors etc,save the documentas a template and then link the document to the item in cause.
Since in an ordinary text box you can't modify the fonts for the selected text only,I tried to use an word pad insertable object, but it dosen't look very good, and I don't know how to save the document.Are there any other solutions, or can you give me some hints about using the wordpad object?
Wordpad To Excel
I need some help on taking select text from Wordpad and putting it into a specified cell in Excel. I cannot just open it in Excel because the data is not delimited. Below is a Wordpad example:
Batch Entry Report for Wednesday, March 10, 2004 (00:00-00:00) (1) wps-osar-ibm
CPU CreateBatc Open Batch CommitBatc CreatImage
------------ ---------- ---------- ---------- ---------- ---------- ---------- ------
%I %K %U %W COUNT DURA COUNT DURA COUNT DURA
-- -- -- ----- ---- ----- ---- ----- ---- ----- ---- ----- ---- ----- ---- ----- ---- 19:00 83 3 3 11 1 0.0 107 0.0 1 0.0 18:45 58 4 25 13 0 * 10 0.0 0 *
I want to grab all of the activity from 19:00 and export that line to Excel. I do not want to grab the data from 18:45 though. Any help is much appreciated.
Selfmake WordPad (.rtf) File
Can you tell me more about WordPad.rtf file, can possible used my-design program (VB) , to make it.
First I have ONE templete .rtf file, so I can view that sources and simple changed that TEXT (example: Date,Name)
First READ file #1
and if "Each Line ~"DATE", changed TODATE date,
if "Each Line ~"NAME", changed new name (Text1.Text )
Save As "new file name"
Thanks a lot.
Wordpad Vs. Notepad For Viewing
I am able to view a file by using the code
strView = "notepad.exe " & FileName
RetVal = Shell(strView, 1)
However, I'd like to use wordpad or an alternate text viewing software to view the file because the columns in the document do not line up in notepad.
i've tried replacing "notepad.exe" with "wordpad.exe" but it doesn't work. does anyone have a suggestion?
Wordpad Object & Font
Hey sorry to ask a stupid question, but I searched and couldn't find any info on this
I created an ascii file by just opening for Output (simple file )
I know that ascii files do not store formatting
I used a ".wri" extension and the shellExecute command to open it in Wordpad.
WHat I am trying to find is an API call or some method of selecting all the text in this doc and changing the font size?
Is this possible?
I couldnt find any info about a wordpad object , but a comment BillSoo made makes me wonder if i can actually use the word object.
any thoughts or help?