This post is to help me answering here:
http://www.excelfox.com/forum/showth...2177#post12177
It is a similar idea as in the last post. The only difference is that the text information is passed via a text file.
So as before, both files should be downloaded to the same place.
File "OpenAndRunMeMacros.xls" should be opened and this time the macro Sub MeMacroTextMies() should be run.
( You do not need to do anything about the text file. That will be made the first time Sub MeMacroTextMies() is run , and subsequently it will be overwritten by each further run of Sub MeMacroTextMies(). )
Sub MeMacroTextMies() running should cause "LibroSociTextMies.xls" to be opened, and as before a similar set of events should take place:
A message box pops up:
LibroSociTextMiesMsgBox.JPG : https://imgur.com/5sAvqPP
LibroSociTextMiesMsgBox.JPG
and then the file "LibroSociTextMies.xls" is modified:
UseCodeLine2.JPG : https://imgur.com/SKeW4MQ
UseCodeLine2.JPG
Coding in "OpenAndRunMeMacros.xls"
Code:Sub MeMacroTextMies() Dim NTes As String: Let NTes = "Ciao" Dim strcFileName As String: Let strcFileName = "Timer.txt" Dim intFile As Long: Let intFile = FreeFile Open ThisWorkbook.Path & "\" & strcFileName For Output As #intFile Write #intFile, NTes Close intFile Application.OnTime EarliestTime:=Now(), Procedure:="AggiornaLibroSociTexties" End Sub Sub AggiornaLibroSociTexties() Dim xlapp As Excel.Application Dim xlBook As Excel.Workbook Dim ExcelPath As String Let ExcelPath = ThisWorkbook.Path & "\" ' CurrentProject.Path & "\" Set xlapp = CreateObject("Excel.Application") Let xlapp.Visible = True Set xlBook = xlapp.Workbooks.Open(ExcelPath & "LibroSociTextMies.xls") xlBook.Close xlapp.Quit Set xlBook = Nothing Set xlapp = Nothing End Sub
Coding in "LibroSociTextMies.xls"
Code:Option Explicit Private Sub Workbook_Open() Dim intFile As Long: Let intFile = FreeFile Dim strcFileName As String: Let strcFileName = "Timer.txt" Open ThisWorkbook.Path & "\" & strcFileName For Input As #intFile Dim NTes As String Input #intFile, NTes Close intFile MsgBox prompt:=NTes Dim xlBook As Workbook Dim rowNo As Long Set xlBook = ThisWorkbook Let rowNo = xlBook.Worksheets("LibroSoci").Range("C:C").Find(What:=NTes, LookIn:=xlValues).Row Let xlBook.Worksheets("LibroSoci").Cells(rowNo, 4).Value = Year(Date) End Sub




Reply With Quote
Bookmarks