Load text into a form

View a text file on a form

Page 1 of 1

4 Replies - 1638 Views - Last Post: 15 July 2009 - 08:50 AM Rate Topic: -----

#1 Irish_Dave  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 12
  • Joined: 14-July 09

Load text into a form

Post icon  Posted 14 July 2009 - 05:16 AM

Hi, I am trying to load a text file into a form so that it can be viewed. I know you can load pictures, but I am trying to load a text file as I want the text to remain in colour. I am writing it in VBA.

I thought about using a picture box control but I have not found it in the additional control on the tools box.
I could use a text box but it loses the text colour, and I can't select a line.
I wont to be able to select two lines and have some code work on the information selected.

Am I just kidding myself, and a form is the wrong way to go?

Any help would be helpful.
Irish_Dave

Is This A Good Question/Topic? 0
  • +

Replies To: Load text into a form

#2 raziel_  Icon User is offline

  • Like a lollipop
  • member icon

Reputation: 469
  • View blog
  • Posts: 4,280
  • Joined: 25-March 09

Re: Load text into a form

Posted 14 July 2009 - 07:36 AM

use datagrid you can color the text and the cells
Was This Post Helpful? 0
  • +
  • -

#3 vb5prgrmr  Icon User is offline

  • D.I.C Lover

Reputation: 109
  • View blog
  • Posts: 1,016
  • Joined: 21-March 09

Re: Load text into a form

Posted 14 July 2009 - 08:38 PM

Use the RTB (Rich TextBox control). Easy to load a file, change font properties for each character if you want (color, name, size, bold, underline, italic, etc).



Good Luck
Was This Post Helpful? 0
  • +
  • -

#4 Irish_Dave  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 12
  • Joined: 14-July 09

Re: Load text into a form

Posted 15 July 2009 - 07:25 AM

Thanks for getting back to me with some ideas.
When I add the Rich Textbox control to my form in Excel I get the following message.

"The subject is not trusted for the specified action"

But I do not know how to rectify it.
Any ideas.


Thanks a lot.
Irish_Dave
Was This Post Helpful? 0
  • +
  • -

#5 vb5prgrmr  Icon User is offline

  • D.I.C Lover

Reputation: 109
  • View blog
  • Posts: 1,016
  • Joined: 21-March 09

Re: Load text into a form

Posted 15 July 2009 - 08:50 AM

Okay, you are using VBA....


Hmmm....


Welllll???


Okay, perhaps a cludge way of doing this... BUT... I was able to add a webbrowser control. Are you familiar with writing HTML? If you are then you could create your html and either write it to a file and use the navigate method or use a varialble with the correct formating...
Option Explicit

Private Sub UserForm_Activate()
WB.Navigate "about:blank"
End Sub

Private Sub UserForm_Click()
WB.document.body.innerhtml = "<html><body>This is a test</body></html>"
End Sub




Perhaps someone else could help if they have an idea...


Good Luck



Oh yeah... Look up in help or this site for reading a file in...

FreeFile Function
Open Statement
Input Function
Line Input Function
Close Statement


Good Luck
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1