#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 31
Default Text Files

How can I store a value in a text file from (1) a cell reference (2) a text
box on a form?

Thanks in advance for your help
--
AJM1949
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default Text Files

Look the Open Statement in the help.

NickHK

"AJM1949" wrote in message
...
How can I store a value in a text file from (1) a cell reference (2) a

text
box on a form?

Thanks in advance for your help
--
AJM1949



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 131
Default Text Files

(1)


Sub SaveCellToTXT()

Set fso = CreateObject _
("Scripting.FileSystemObject")

Set txtFile = fso.CreateTextFile _
("C:\test1.txt", True)

txtFile.WriteLine _
ActiveWorkbook.Sheets(1).Cells(1, 1)

txtFile.Close

End Sub

(2)

Sub SaveTextBoxToTXT()

Set fso = CreateObject _
("Scripting.FileSystemObject")

Set txtFile = fso.CreateTextFile _
("C:\test2.txt", True)

'UserForm1.TextBox1.Value = "test"

txtFile.WriteLine _
UserForm1.TextBox1.Value

txtFile.Close


End Sub

Hope that helps.

--
urkec


"AJM1949" wrote:

How can I store a value in a text file from (1) a cell reference (2) a text
box on a form?

Thanks in advance for your help
--
AJM1949

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 31
Default Text Files

Thanks very much. That seems to work fine.
I also need some help to read these stored values back into a cell.
Can you help with this
--
AJM1949


"urkec" wrote:

(1)


Sub SaveCellToTXT()

Set fso = CreateObject _
("Scripting.FileSystemObject")

Set txtFile = fso.CreateTextFile _
("C:\test1.txt", True)

txtFile.WriteLine _
ActiveWorkbook.Sheets(1).Cells(1, 1)

txtFile.Close

End Sub

(2)

Sub SaveTextBoxToTXT()

Set fso = CreateObject _
("Scripting.FileSystemObject")

Set txtFile = fso.CreateTextFile _
("C:\test2.txt", True)

'UserForm1.TextBox1.Value = "test"

txtFile.WriteLine _
UserForm1.TextBox1.Value

txtFile.Close


End Sub

Hope that helps.

--
urkec


"AJM1949" wrote:

How can I store a value in a text file from (1) a cell reference (2) a text
box on a form?

Thanks in advance for your help
--
AJM1949

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 131
Default Text Files

Sub LoadTXTToCell(filePath As String)

ForReading = 1

Set fso = CreateObject _
("Scripting.FileSystemObject")

If fso.FileExists(filePath) Then
Set txtFile = fso.OpenTextFile _
(filePath, ForReading)
Else
Exit Sub
End If

ActiveWorkbook.Sheets(1).Cells(1, 1) = _
txtFile.ReadLine
'or
'txtFile.ReadAll

txtFile.Close

End Sub

--
urkec


"AJM1949" wrote:

Thanks very much. That seems to work fine.
I also need some help to read these stored values back into a cell.
Can you help with this
--
AJM1949


"urkec" wrote:

(1)


Sub SaveCellToTXT()

Set fso = CreateObject _
("Scripting.FileSystemObject")

Set txtFile = fso.CreateTextFile _
("C:\test1.txt", True)

txtFile.WriteLine _
ActiveWorkbook.Sheets(1).Cells(1, 1)

txtFile.Close

End Sub

(2)

Sub SaveTextBoxToTXT()

Set fso = CreateObject _
("Scripting.FileSystemObject")

Set txtFile = fso.CreateTextFile _
("C:\test2.txt", True)

'UserForm1.TextBox1.Value = "test"

txtFile.WriteLine _
UserForm1.TextBox1.Value

txtFile.Close


End Sub

Hope that helps.

--
urkec


"AJM1949" wrote:

How can I store a value in a text file from (1) a cell reference (2) a text
box on a form?

Thanks in advance for your help
--
AJM1949



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 31
Default Text Files

Hi

Thanks for the code. I seem to be missing something. I am trying to save
ithe text file value to a named range but can't seem to make it work. I am
still learning and appreciate the help given

--
AJM1949


"urkec" wrote:

Sub LoadTXTToCell(filePath As String)

ForReading = 1

Set fso = CreateObject _
("Scripting.FileSystemObject")

If fso.FileExists(filePath) Then
Set txtFile = fso.OpenTextFile _
(filePath, ForReading)
Else
Exit Sub
End If

ActiveWorkbook.Sheets(1).Cells(1, 1) = _
txtFile.ReadLine
'or
'txtFile.ReadAll

txtFile.Close

End Sub

--
urkec


"AJM1949" wrote:

Thanks very much. That seems to work fine.
I also need some help to read these stored values back into a cell.
Can you help with this
--
AJM1949


"urkec" wrote:

(1)


Sub SaveCellToTXT()

Set fso = CreateObject _
("Scripting.FileSystemObject")

Set txtFile = fso.CreateTextFile _
("C:\test1.txt", True)

txtFile.WriteLine _
ActiveWorkbook.Sheets(1).Cells(1, 1)

txtFile.Close

End Sub

(2)

Sub SaveTextBoxToTXT()

Set fso = CreateObject _
("Scripting.FileSystemObject")

Set txtFile = fso.CreateTextFile _
("C:\test2.txt", True)

'UserForm1.TextBox1.Value = "test"

txtFile.WriteLine _
UserForm1.TextBox1.Value

txtFile.Close


End Sub

Hope that helps.

--
urkec


"AJM1949" wrote:

How can I store a value in a text file from (1) a cell reference (2) a text
box on a form?

Thanks in advance for your help
--
AJM1949

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 131
Default Text Files

Are you getting any errors or it just doesn't work?

--
urkec


"AJM1949" wrote:

Hi

Thanks for the code. I seem to be missing something. I am trying to save
ithe text file value to a named range but can't seem to make it work. I am
still learning and appreciate the help given

--
AJM1949


"urkec" wrote:

Sub LoadTXTToCell(filePath As String)

ForReading = 1

Set fso = CreateObject _
("Scripting.FileSystemObject")

If fso.FileExists(filePath) Then
Set txtFile = fso.OpenTextFile _
(filePath, ForReading)
Else
Exit Sub
End If

ActiveWorkbook.Sheets(1).Cells(1, 1) = _
txtFile.ReadLine
'or
'txtFile.ReadAll

txtFile.Close

End Sub

--
urkec


"AJM1949" wrote:

Thanks very much. That seems to work fine.
I also need some help to read these stored values back into a cell.
Can you help with this
--
AJM1949


"urkec" wrote:

(1)


Sub SaveCellToTXT()

Set fso = CreateObject _
("Scripting.FileSystemObject")

Set txtFile = fso.CreateTextFile _
("C:\test1.txt", True)

txtFile.WriteLine _
ActiveWorkbook.Sheets(1).Cells(1, 1)

txtFile.Close

End Sub

(2)

Sub SaveTextBoxToTXT()

Set fso = CreateObject _
("Scripting.FileSystemObject")

Set txtFile = fso.CreateTextFile _
("C:\test2.txt", True)

'UserForm1.TextBox1.Value = "test"

txtFile.WriteLine _
UserForm1.TextBox1.Value

txtFile.Close


End Sub

Hope that helps.

--
urkec


"AJM1949" wrote:

How can I store a value in a text file from (1) a cell reference (2) a text
box on a form?

Thanks in advance for your help
--
AJM1949

  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 31
Default Text Files

Sorry to be a bit slow replying. I got a bit side tracked with another
project. Thanks very much for your assistance. I now have all the code
working fine.
--
AJM1949


"urkec" wrote:

(1)


Sub SaveCellToTXT()

Set fso = CreateObject _
("Scripting.FileSystemObject")

Set txtFile = fso.CreateTextFile _
("C:\test1.txt", True)

txtFile.WriteLine _
ActiveWorkbook.Sheets(1).Cells(1, 1)

txtFile.Close

End Sub

(2)

Sub SaveTextBoxToTXT()

Set fso = CreateObject _
("Scripting.FileSystemObject")

Set txtFile = fso.CreateTextFile _
("C:\test2.txt", True)

'UserForm1.TextBox1.Value = "test"

txtFile.WriteLine _
UserForm1.TextBox1.Value

txtFile.Close


End Sub

Hope that helps.

--
urkec


"AJM1949" wrote:

How can I store a value in a text file from (1) a cell reference (2) a text
box on a form?

Thanks in advance for your help
--
AJM1949

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
Excel (xls) files spontaneously converting to text files Be-jamin Excel Discussion (Misc queries) 0 November 18th 08 05:31 PM
how do i convert text files into CSV files? airpr23 Excel Discussion (Misc queries) 2 February 28th 07 12:56 AM
Macro to open *.dat files and save as .txt (comma delimited text files) [email protected] Excel Programming 2 November 30th 05 05:50 AM
copy subfolders, replace text in files and save files in copied subfolders pieros Excel Programming 0 November 1st 05 12:08 PM
open some txt files ,find text , copy the text before that to a single cell gus Excel Programming 2 July 11th 05 05:40 PM


All times are GMT +1. The time now is 10:11 AM.

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

About Us

"It's about Microsoft Excel"