Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- '---- I Module ----
- Option Explicit
- Sub WriteCS()
- Dim fso As FileSystemObject
- Dim fsoFile As TextStream
- Set fso = New FileSystemObject
- ' TristateTrue - uzycie unicode
- Set fsoFile = fso.OpenTextFile(GetPath & "\Test.cs", ForWriting, True, TristateTrue)
- fsoFile.WriteLine "Hello world"
- fsoFile.Close
- End Sub
- '---- II Module ----
- 'deklaracja zmiennych musi byc jawna
- Option Explicit
- ' function - zwraca wartosc
- Function GetPath()
- Dim path As String
- 'pobranie sciezki pliku
- path = ThisWorkbook.path
- Dim processedPath As String
- processedPath = ""
- ' przedrostek sciezki
- Dim pathSuffix As String
- pathSuffix = "\Scripts\Static\StringTables"
- ' Wyswieltenie wszystkiego do ostatniego znaku "/"
- ' ---
- Dim cLoop As Long
- Dim cLimit As Long
- cLimit = Len(path)
- For cLoop = 1 To cLimit
- If Mid(path, cLoop, 1) = "\" Then
- processedPath = Left(path, cLoop - 1)
- End If
- Next cLoop
- ' ---
- ' wyswietlenie sciezki
- ' MsgBox path & vbCrLf & processedPath
- GetPath = processedPath & pathSuffix
- End Function
- Sub Test()
- MsgBox GetPath
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement