Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Export values in a text file

In the B9 cell I have values that they change dynamically.
Is possible , through VBA, than Excel notices of such variations and
to every change writes those values in a text file with this
structu

DATE HOUR VALUE
10/30/2003 10:31 5,6
10/30/2003 11:59 5,9
10/31/2003 8:58 6

ETC.

Can you help me?

Thanks
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Export values in a text file

Assume this change is caused by some DDE connection

Look at SetLinkOnData property of the Workbook object to designate a macro
to run when there is a change.

Then have this macro write the data.

In xl2000 and later, I believe you can use the change event for this.

http://www.cpearson.com/excel/event.htm for a description of events.

--
Regards,
Tom Ogilvy
"Matrix" wrote in message
...
In the B9 cell I have values that they change dynamically.
Is possible , through VBA, than Excel notices of such variations and
to every change writes those values in a text file with this
structu

DATE HOUR VALUE
10/30/2003 10:31 5,6
10/30/2003 11:59 5,9
10/31/2003 8:58 6

ETC.

Can you help me?

Thanks



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Export values in a text file

On Fri, 31 Oct 2003 14:51:18 -0500, "Tom Ogilvy"
wrote:


Then have this macro write the data.

In xl2000 and later, I believe you can use the change event for this.

http://www.cpearson.com/excel/event.htm for a description of events.


If it isn't very difficult, can you give me an exemple of vba code?
I'm a novice

Thanks
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Export values in a text file

You can get sample code he
http://support.microsoft.com/support...eio/fileio.asp
File Access with Visual Basic® for Applications


--
Regards,
Tom Ogilvy

Matrix wrote in message
...
On Fri, 31 Oct 2003 14:51:18 -0500, "Tom Ogilvy"
wrote:


Then have this macro write the data.

In xl2000 and later, I believe you can use the change event for this.

http://www.cpearson.com/excel/event.htm for a description of events.


If it isn't very difficult, can you give me an exemple of vba code?
I'm a novice

Thanks



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Export values in a text file

On Sat, 1 Nov 2003 11:48:27 -0500, "Tom Ogilvy"
wrote:

You can get sample code he
http://support.microsoft.com/support...eio/fileio.asp
File Access with Visual Basic® for Applications



Thanks for support.
I've written this code, but it doesn't work.
Can you tell me why?


Sub Worksheet_Change(ByVal Target As Range)


If Target.Value = Foglio2.Range("D9").Value Then MyTxtFile

End Sub


Sub MyTxtFile()
Const Percorso = "c:\txtExport.txt"

Open Percorso For Append As #1
Print #1, Date, Time, Cells(9, 4).Value
Close #1

End Sub




  #6   Report Post  
Posted to microsoft.public.excel.programming
jaf jaf is offline
external usenet poster
 
Posts: 300
Default Export values in a text file

Hi,
Target.Value would be the contents of D9.
For the event to evaluate to true and run Mytexfile you have to give it the
cell address so it knows which cell is the current cell.
This way you can evaluate more than one cell.

Sub Worksheet_Change(ByVal Target As Range)

If Target.Address = "$D$9" Then mytxtfile

End Sub

Sub MyTxtFile()
Const Percorso = "c:\txtExport.txt"

Open Percorso For Append As #1
Print #1, Date, Time, Cells(9, 4).Value
Close #1

End Sub

--

John

johnf202 at hotmail dot com


"Matrix" wrote in message
...
On Sat, 1 Nov 2003 11:48:27 -0500, "Tom Ogilvy"
wrote:

You can get sample code he
http://support.microsoft.com/support...eio/fileio.asp
File Access with Visual Basic® for Applications



Thanks for support.
I've written this code, but it doesn't work.
Can you tell me why?


Sub Worksheet_Change(ByVal Target As Range)


If Target.Value = Foglio2.Range("D9").Value Then MyTxtFile

End Sub


Sub MyTxtFile()
Const Percorso = "c:\txtExport.txt"

Open Percorso For Append As #1
Print #1, Date, Time, Cells(9, 4).Value
Close #1

End Sub




  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Export values in a text file

On Sun, 2 Nov 2003 08:27:45 -0500, "jaf" wrote:

Hi,
Target.Value would be the contents of D9.
For the event to evaluate to true and run Mytexfile you have to give it the
cell address so it knows which cell is the current cell.
This way you can evaluate more than one cell.



Ok, now it works, but there is a big problem
Change Event doesn't work with DDE link:
http://support.microsoft.com/?kbid=172832

The right solution is SetLinkOnData, but i haven't understood how it
works.

Please Jaf can you tell me how i can adapt previous vba code with
SetLinkOnData?

Thanks a lot
  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Export values in a text file

Why not read the sample code given in the link you show. It shows you how
it works. Each link has to be set separately and a macro assigned. Since
you only have one cell, D9, that would only need one macro assignment - the
macro would be Mytxtfile. I found you need to do to a calculate in the in
the macro to get the updated value.

Recall I told you about SetLinkOnData in my first post and the fact that
Change only works in xl2000 and later, just like in the article.

--
Regards,
Tom Ogilvy

Matrix wrote in message
...
On Sun, 2 Nov 2003 08:27:45 -0500, "jaf" wrote:

Hi,
Target.Value would be the contents of D9.
For the event to evaluate to true and run Mytexfile you have to give it

the
cell address so it knows which cell is the current cell.
This way you can evaluate more than one cell.



Ok, now it works, but there is a big problem
Change Event doesn't work with DDE link:
http://support.microsoft.com/?kbid=172832

The right solution is SetLinkOnData, but i haven't understood how it
works.

Please Jaf can you tell me how i can adapt previous vba code with
SetLinkOnData?

Thanks a lot



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
Export range to text file Matthew Scheperle Excel Discussion (Misc queries) 1 March 21st 10 03:30 AM
How to Export as text file with NO delimiters or modifications? MojoNixon Excel Discussion (Misc queries) 5 August 15th 06 09:37 PM
How can I export text from excel autoshapes to a text file? Donncha Excel Discussion (Misc queries) 0 July 20th 06 04:58 PM
Cell export to Text File? Steve Excel Discussion (Misc queries) 3 December 7th 05 03:13 PM
Export excel file to semicolon delimited text file capitan Excel Discussion (Misc queries) 5 April 7th 05 03:06 AM


All times are GMT +1. The time now is 09:25 PM.

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"