I've grab a code in this forum to get a striung value from txt file to a calc cell.
The code works well but its constantly fetching the value and i only need to get the value once when opening the calc book.
Could you hep me modifying this code please.
This is the code
Code: Select all
Dim iRun As Integer iRun =1 While iRun =1 Dim iNumber As Integer Dim delay As Integer 'delay between updates Dim sLine As String Dim aFile As String Dim update As String Dim oSheet : oSheet = ThisComponent.Sheets.getByIndex(1) 'Index 0 is Sheet1, Index 1 is Sheet2, etc. Dim oCell : oCell = oSheet.getCellByPosition(1,0) 'Both row and column indexes start with 0: A1 is 0,0 - A2 is 1,0 - B1 is 0,1 Dim iCell : iCell = oSheet.getCellByPosition(0,1) delay = 5000 iCell.setString(" ") wait delay 'wait duration aFile = "c:\encomendas\Bar.txt" iNumber = Freefile Open aFile For Input As iNumber While not eof(iNumber) Line Input #iNumber, sLine If sLine <>"" then end if wend Close #iNumber oCell.setString(sLine) rem iCell.setString("*Updating*") rem wait delay ' Wait duration Wend