• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 330
  • Last Modified:

richtextbox to notepad file

How could one copy the contents of richtextbox to a notepad file.

Thank you
0
vern123
Asked:
vern123
  • 4
  • 3
1 Solution
 
watyCommented:
You have to use the text property of the RTF.
You have several solution to add it in your notepad :
1: Use the Clipboard
     Clipboard.Clear
     Clipboard.SetText rtf.SelText, vbCFText
   After that, you can paste the code in the notepad

2: Use file. Save the text to a file, and load that file in the notepad
0
 
vern123Author Commented:
Could I have sample code for option 2, thank you.
0
 
vern123Author Commented:
I dont want to do this manually,
It should be a procedure

0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
watyCommented:
Don't forget to select the needed text to save.
rtf.SelStart = 0
rtf.SelLength = Len(rtf.Text)

   nFile = FreeFile
   Open sFile For Binary Access Write As #nFile

   Put #nFile, , rtf.SelText

   Close #nFile

0
 
vern123Author Commented:
  Dim pathname As String
   pathname = "C:/prod/temp.txt"
 
   RichTextBox1.SelStart = 0
   RichTextBox1.SelLength = Len(RichTextBox1.Text)

   'nFile = FreeFile 'what is this?
   Open pathname For Binary Access Write As #nFile
   Put #nFile, , RichTextBox1.SelText
   Close #nFile
 
   Shell "notepad " + pathname, 3
 
Thank for help,
does not know #nfile? what is wrong above?

   
0
 
watyCommented:
nFile = Freefile :
 It takes a new free handle when opening/writing to a file.
0
 
vern123Author Commented:
:)
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now