Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Opening textfile in textbox + moving to top
Found this code for opening a textfile in a textbox on a custom VBA form:
Private Sub UserForm_Initialize() Dim hFile As Long Dim sFilename As String sFilename = conLinkHelpdesk hFile = FreeFile Open sFilename For Input As #hFile txtText.Text = Input$(LOF(hFile), hFile) Close #hFile End Sub Works fine, but when the form opens, the cursor is at the bottom, which causes the end of the textfile to show, rather than the beginning. Is there a way to correct this? Gustaf |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Opening textfile in textbox + moving to top
Please refer the below link
http://support.microsoft.com/kb/209231 You can also use the Line input statement to retrieve a line at a time -- If this post helps click Yes --------------- Jacob Skaria "Gustaf" wrote: Found this code for opening a textfile in a textbox on a custom VBA form: Private Sub UserForm_Initialize() Dim hFile As Long Dim sFilename As String sFilename = conLinkHelpdesk hFile = FreeFile Open sFilename For Input As #hFile txtText.Text = Input$(LOF(hFile), hFile) Close #hFile End Sub Works fine, but when the form opens, the cursor is at the bottom, which causes the end of the textfile to show, rather than the beginning. Is there a way to correct this? Gustaf |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Opening textfile in textbox + moving to top
Oops...You can use this code after closing the file
UserForm1.TextBox1.SetFocus UserForm1.TextBox1.SelStart = 0 If this post helps click Yes --------------- Jacob Skaria "Jacob Skaria" wrote: Please refer the below link http://support.microsoft.com/kb/209231 You can also use the Line input statement to retrieve a line at a time -- If this post helps click Yes --------------- Jacob Skaria "Gustaf" wrote: Found this code for opening a textfile in a textbox on a custom VBA form: Private Sub UserForm_Initialize() Dim hFile As Long Dim sFilename As String sFilename = conLinkHelpdesk hFile = FreeFile Open sFilename For Input As #hFile txtText.Text = Input$(LOF(hFile), hFile) Close #hFile End Sub Works fine, but when the form opens, the cursor is at the bottom, which causes the end of the textfile to show, rather than the beginning. Is there a way to correct this? Gustaf |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Opening textfile in textbox + moving to top
Jacob Skaria wrote:
UserForm1.TextBox1.SetFocus UserForm1.TextBox1.SelStart = 0 Nice and tidy. Thank you very much! If this post helps click Yes Click yes? Gustaf |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
TextBox validation before moving to next | Excel Programming | |||
Moving Data on opening Excel | New Users to Excel | |||
Textbox keeps moving | Excel Programming | |||
Opening and saving textfile into XLS | Excel Programming | |||
Code for moving textbox | Excel Programming |