Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 26
Default creating and saving data from a userform

Hello

I'm totally at a loss as to how I can achieve this, but this site has helped
me in the pass and I'm hoping you will be able to help me now.

I have an excel program which stays in a share drive. Staff are then able
to open up the excel program which is all VB. The first form they encounter
is to setup their signature block. There are four textboxes, Eg: name, state,
telephone etc. Currently when exiting out of this program their signature
block is not saved. I'm hoping to create a text document via notepad or
similiar file which would save their signature block in their own drive.

I thought of creating two command buttons, one to save and another to update
if needed. The save button would check in their own drive if there was such
as file (eg: signatureblock.txt) and if not would create on. The update
button would again check if there was such a file, it would either delete the
old one and then create a new one or create a new one.

I was hoping that next time that staff member opened the program, the
program would automatically extract the signature block information and place
this info appropriately in the correct textboxes.

I'm hoping for any guidance or assistance.
Many thanks in advance.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default creating and saving data from a userform

Hi,

This uses the activate and terminate userform events. It will read or create
a text file that holds the text in textbox1 on the userfrom and automatically
populate that into the textbox if the file exists.

Private Sub UserForm_Activate()
On Error Resume Next
Dim FileNum As Integer
Close
FileNum = FreeFile
Open "c:\nametext.txt" For Input As #FileNum
Input #FileNum, usrname
Close
TextBox1.Text = usrname
End Sub


Private Sub UserForm_Terminate()
Dim FileNum As Integer
Close
FileNum = FreeFile
Open "c:\nametext.txt" For Output As #FileNum
Write #FileNum, TextBox1.Text
Close
End Sub

Mike

"bluewatermist" wrote:

Hello

I'm totally at a loss as to how I can achieve this, but this site has helped
me in the pass and I'm hoping you will be able to help me now.

I have an excel program which stays in a share drive. Staff are then able
to open up the excel program which is all VB. The first form they encounter
is to setup their signature block. There are four textboxes, Eg: name, state,
telephone etc. Currently when exiting out of this program their signature
block is not saved. I'm hoping to create a text document via notepad or
similiar file which would save their signature block in their own drive.

I thought of creating two command buttons, one to save and another to update
if needed. The save button would check in their own drive if there was such
as file (eg: signatureblock.txt) and if not would create on. The update
button would again check if there was such a file, it would either delete the
old one and then create a new one or create a new one.

I was hoping that next time that staff member opened the program, the
program would automatically extract the signature block information and place
this info appropriately in the correct textboxes.

I'm hoping for any guidance or assistance.
Many thanks in advance.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 26
Default creating and saving data from a userform

Hi Mike

Thank you for such a quick reply. For the first textbox it works but i
can't seem to add several textboxes after it. Can you suggest anything.

many thanks



"Mike H" wrote:

Hi,

This uses the activate and terminate userform events. It will read or create
a text file that holds the text in textbox1 on the userfrom and automatically
populate that into the textbox if the file exists.

Private Sub UserForm_Activate()
On Error Resume Next
Dim FileNum As Integer
Close
FileNum = FreeFile
Open "c:\nametext.txt" For Input As #FileNum
Input #FileNum, usrname
Close
TextBox1.Text = usrname
End Sub


Private Sub UserForm_Terminate()
Dim FileNum As Integer
Close
FileNum = FreeFile
Open "c:\nametext.txt" For Output As #FileNum
Write #FileNum, TextBox1.Text
Close
End Sub

Mike

"bluewatermist" wrote:

Hello

I'm totally at a loss as to how I can achieve this, but this site has helped
me in the pass and I'm hoping you will be able to help me now.

I have an excel program which stays in a share drive. Staff are then able
to open up the excel program which is all VB. The first form they encounter
is to setup their signature block. There are four textboxes, Eg: name, state,
telephone etc. Currently when exiting out of this program their signature
block is not saved. I'm hoping to create a text document via notepad or
similiar file which would save their signature block in their own drive.

I thought of creating two command buttons, one to save and another to update
if needed. The save button would check in their own drive if there was such
as file (eg: signatureblock.txt) and if not would create on. The update
button would again check if there was such a file, it would either delete the
old one and then create a new one or create a new one.

I was hoping that next time that staff member opened the program, the
program would automatically extract the signature block information and place
this info appropriately in the correct textboxes.

I'm hoping for any guidance or assistance.
Many thanks in advance.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default creating and saving data from a userform

Hi,

It all starts getting a bit messy because i don't fully understand what you
tring to do but this now writes multiple values to the data file and reads
them back in again when the userfom loads.

the way it works is that the text file is comma delimited and looks
something like this

"Mike","In","England"

Private Sub UserForm_Activate()
On Error Resume Next
Dim FileNum As Integer
Close
FileNum = FreeFile
Open "c:\nametext.txt" For Input As #FileNum
Input #FileNum, usrname, Address, somethingelse
Close
TextBox1.Text = usrname
TextBox2.Text = Address
TextBox3.Text = somethingelse
End Sub

Private Sub UserForm_Terminate()
Dim FileNum As Integer
Close
FileNum = FreeFile
Open "c:\nametext.txt" For Output As #FileNum
Write #FileNum, TextBox1.Text, TextBox2.Text, TextBox3.Text
Close
End Sub


Mike

"bluewatermist" wrote:

Hi Mike

Thank you for such a quick reply. For the first textbox it works but i
can't seem to add several textboxes after it. Can you suggest anything.

many thanks



"Mike H" wrote:

Hi,

This uses the activate and terminate userform events. It will read or create
a text file that holds the text in textbox1 on the userfrom and automatically
populate that into the textbox if the file exists.

Private Sub UserForm_Activate()
On Error Resume Next
Dim FileNum As Integer
Close
FileNum = FreeFile
Open "c:\nametext.txt" For Input As #FileNum
Input #FileNum, usrname
Close
TextBox1.Text = usrname
End Sub


Private Sub UserForm_Terminate()
Dim FileNum As Integer
Close
FileNum = FreeFile
Open "c:\nametext.txt" For Output As #FileNum
Write #FileNum, TextBox1.Text
Close
End Sub

Mike

"bluewatermist" wrote:

Hello

I'm totally at a loss as to how I can achieve this, but this site has helped
me in the pass and I'm hoping you will be able to help me now.

I have an excel program which stays in a share drive. Staff are then able
to open up the excel program which is all VB. The first form they encounter
is to setup their signature block. There are four textboxes, Eg: name, state,
telephone etc. Currently when exiting out of this program their signature
block is not saved. I'm hoping to create a text document via notepad or
similiar file which would save their signature block in their own drive.

I thought of creating two command buttons, one to save and another to update
if needed. The save button would check in their own drive if there was such
as file (eg: signatureblock.txt) and if not would create on. The update
button would again check if there was such a file, it would either delete the
old one and then create a new one or create a new one.

I was hoping that next time that staff member opened the program, the
program would automatically extract the signature block information and place
this info appropriately in the correct textboxes.

I'm hoping for any guidance or assistance.
Many thanks in advance.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 26
Default creating and saving data from a userform

Hi Mike

You're brilliant! That's exactly what I needed. Thank you so much for your
support.

Best Regards


"Mike H" wrote:

Hi,

It all starts getting a bit messy because i don't fully understand what you
tring to do but this now writes multiple values to the data file and reads
them back in again when the userfom loads.

the way it works is that the text file is comma delimited and looks
something like this

"Mike","In","England"

Private Sub UserForm_Activate()
On Error Resume Next
Dim FileNum As Integer
Close
FileNum = FreeFile
Open "c:\nametext.txt" For Input As #FileNum
Input #FileNum, usrname, Address, somethingelse
Close
TextBox1.Text = usrname
TextBox2.Text = Address
TextBox3.Text = somethingelse
End Sub

Private Sub UserForm_Terminate()
Dim FileNum As Integer
Close
FileNum = FreeFile
Open "c:\nametext.txt" For Output As #FileNum
Write #FileNum, TextBox1.Text, TextBox2.Text, TextBox3.Text
Close
End Sub


Mike

"bluewatermist" wrote:

Hi Mike

Thank you for such a quick reply. For the first textbox it works but i
can't seem to add several textboxes after it. Can you suggest anything.

many thanks



"Mike H" wrote:

Hi,

This uses the activate and terminate userform events. It will read or create
a text file that holds the text in textbox1 on the userfrom and automatically
populate that into the textbox if the file exists.

Private Sub UserForm_Activate()
On Error Resume Next
Dim FileNum As Integer
Close
FileNum = FreeFile
Open "c:\nametext.txt" For Input As #FileNum
Input #FileNum, usrname
Close
TextBox1.Text = usrname
End Sub


Private Sub UserForm_Terminate()
Dim FileNum As Integer
Close
FileNum = FreeFile
Open "c:\nametext.txt" For Output As #FileNum
Write #FileNum, TextBox1.Text
Close
End Sub

Mike

"bluewatermist" wrote:

Hello

I'm totally at a loss as to how I can achieve this, but this site has helped
me in the pass and I'm hoping you will be able to help me now.

I have an excel program which stays in a share drive. Staff are then able
to open up the excel program which is all VB. The first form they encounter
is to setup their signature block. There are four textboxes, Eg: name, state,
telephone etc. Currently when exiting out of this program their signature
block is not saved. I'm hoping to create a text document via notepad or
similiar file which would save their signature block in their own drive.

I thought of creating two command buttons, one to save and another to update
if needed. The save button would check in their own drive if there was such
as file (eg: signatureblock.txt) and if not would create on. The update
button would again check if there was such a file, it would either delete the
old one and then create a new one or create a new one.

I was hoping that next time that staff member opened the program, the
program would automatically extract the signature block information and place
this info appropriately in the correct textboxes.

I'm hoping for any guidance or assistance.
Many thanks in advance.



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Saving Userform as Gif Robert[_24_] Excel Programming 7 June 13th 13 05:12 AM
Saving information between uses? (Userform) PaulW Excel Programming 1 March 30th 07 02:31 PM
userform textboxes saving numerical data as text in worksheet buckchow[_3_] Excel Programming 0 January 16th 07 05:06 AM
Creating/Saving an .xla file aniamc Excel Programming 4 May 13th 04 11:31 PM
Creating a Data Entry Userform spurtniq[_8_] Excel Programming 1 January 8th 04 05:48 AM


All times are GMT +1. The time now is 07:43 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"