Line 1: |
Line 1: |
| | | |
− | ==Sectors== | + | ==Code== |
| <source> | | <source> |
| + | ' The advantage of correctly typing fso as FileSystemObject is to make autocompletion |
| + | ' (Intellisense) work, which helps you avoid typos and lets you discover other useful |
| + | ' methods of the FileSystemObject |
| + | Dim fso As FileSystemObject |
| + | Set fso = New FileSystemObject |
| + | Dim fileStream As TextStream |
| + | ' Here the actual file is created and opened for write access |
| + | Set fileStream = fso.CreateTextFile(filePath) |
| + | ' Write something to the file |
| + | Dim db As Database |
| + | Dim MyRS As DAO.Recordset |
| + | Dim MyRS2 As DAO.Recordset |
| + | Dim linex As String, liney1 As String, liney2 As String |
| + | Dim nCounter As Integer |
| + | Set db = CurrentDb() |
| + | Set MyRS = db.OpenRecordset("NASDAQ") |
| + | Set MyRS2 = db.OpenRecordset("Daily_Trade") |
| + | MyRS.MoveFirst |
| + | ' |
| + | fileStream.WriteLine "==Sectors==" |
| + | fileStream.WriteLine "==" & Me.Sector & "==" |
| + | fileStream.WriteLine "{| {{Table|sort|class=left}}" |
| + | fileStream.WriteLine "! Symbol !! Security Name !! Exchange !! ETF !! Chart" |
| + | fileStream.WriteLine "|-" |
| + | ' |
| While Not MyRS.EOF | | While Not MyRS.EOF |
| If MyRS("Sector") = Me.Sector Then | | If MyRS("Sector") = Me.Sector Then |
Line 32: |
Line 57: |
| MyRS.MoveNext | | MyRS.MoveNext |
| Wend | | Wend |
| + | |
| + | fileStream.WriteLine "|}" |
| + | |
| + | |
| + | ' Close it, so it is not locked anymore |
| + | fileStream.Close |
| + | |
| + | MyRS.Close |
| + | Set db = Nothing |
| + | Set MyRS = Nothing |
| + | Set MyRS2 = Nothing |
| + | ' Here is another great method of the FileSystemObject that checks if a file exists |
| + | |
| + | |
| + | |
| + | |
| + | |
| </source> | | </source> |
| | | |