Advertisement
Guest User

Untitled

a guest
Oct 17th, 2019
187
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.85 KB | None | 0 0
  1. Dim myFile As String, text As String, textline As String, posLat As Integer, posLong As Integer, myPath As String, OtherNumber As Integer, NumberToLetter As String, Startnumber As Integer
  2. Dim CheckAgainst, CheckAgainst2, InformationText, ProtectionLine As String
  3. Dim ProperLinePosition As Integer, DontSkip As Boolean
  4.  
  5. Sub setEU4File()
  6.  
  7. 'myPath = (Application.DefaultFilePath & "\")
  8. ' myPath = "C:\Program Files (x86)\Steam\steamapps\common\Europa Universalis IV\history\provinces\"
  9. 'C:\Users\Tjeerdsma\Documents\Paradox Interactive\Europa Universalis IV\mod\Imperialism-Reinvigorated\history\provinces
  10. myPath = (Application.DefaultFilePath & "\Paradox Interactive\Europa Universalis IV\mod\Imperialism-Reinvigorated\history\provinces\")
  11.  
  12. Dim fname As Variant
  13.  
  14. 'BASE VARIABLES
  15.  
  16. Startnumber = 1 'NUMBER TO START LOOKING FOR
  17. BaseLimit = 5000 'FILES IT WILL LOOK FOR PAST STARTNUMBER
  18. OtherNumber = 1 'RESET NUMBER FOR PROPER FUNCTIONING
  19.  
  20. 'LOOP ALL FILES
  21.  
  22. For Base = 1 To BaseLimit
  23.  
  24. 'MsgBox myPath
  25.  
  26. fname = Dir(myPath & CStr(Startnumber) & "-*.txt")
  27.  
  28. 'MsgBox fname
  29.  
  30. 'CONVERT NUM TO LETTER SUB
  31.  
  32. Number2Letter
  33.  
  34. 'WRITE DOWN EASY INFO INTO CONVERTEDINFO SHEET
  35.  
  36. Worksheets("ConvertedInfo").Cells(OtherNumber, 3).Value = Startnumber
  37. fullstring = CStr(fname)
  38. ComplexName = Replace(fullstring, (CStr(Startnumber) & " - "), "")
  39. ComplexName = Replace(ComplexName, ".txt", "")
  40. Worksheets("ConvertedInfo").Cells(OtherNumber, 4).Value = ComplexName
  41. Worksheets("ConvertedInfo").Cells(OtherNumber, 5).Value = Worksheets("ConvertedInfo").Cells(OtherNumber, 4).Value
  42.  
  43. 'COPY OVER INFO INTO BASEINFO SHEET
  44.  
  45. If fname <> "" Then
  46. myFile = myPath & fname
  47. OpenEU4File
  48. End If
  49.  
  50. Startnumber = Startnumber + 1
  51. OtherNumber = OtherNumber + 1
  52.  
  53. Next Base
  54.  
  55. End Sub
  56.  
  57. Sub OpenEU4File()
  58.  
  59. 'myFile = Application.GetOpenFilename()
  60.  
  61. Open myFile For Input As #1
  62.  
  63. Number = 1
  64. text = ""
  65.  
  66. Do Until EOF(1)
  67. Line Input #1, textline
  68. ComplexRange = NumberToLetter + CStr(Number)
  69. 'MsgBox ComplexRange
  70. Worksheets("BaseInfo").Range(ComplexRange) = textline
  71. 'text = text & textline & vbNewLine
  72. 'MsgBox text
  73. Number = Number + 1
  74.  
  75. 'WRITE DOWN COMPLEX INFO INTO CONVERTEDINFO SHEET
  76.  
  77. 'CHECK FOR CERTAIN LINE AND DO X
  78.  
  79. InformationText = textline
  80. ProtectionLine = "= {" 'Tries to make sure history things dont get looked into
  81.  
  82. If InStr(InformationText, ProtectionLine) <> 0 Then
  83. Close #1
  84. Exit Sub
  85. Else
  86.  
  87. CheckAgainst = "capital ="
  88. CheckAgainst2 = "capital"
  89. ProperLinePosition = 10
  90. DontSkip = True
  91. WriteThings 'Runs code with previous Variables
  92.  
  93. CheckAgainst = "culture ="
  94. CheckAgainst2 = "culture"
  95. ProperLinePosition = 11
  96. DontSkip = True
  97. WriteThings 'Runs code with previous Variables
  98.  
  99. CheckAgainst = "religion ="
  100. CheckAgainst2 = "religion"
  101. ProperLinePosition = 13
  102. DontSkip = True
  103. WriteThings 'Runs code with previous Variables
  104.  
  105. CheckAgainst = "hre ="
  106. CheckAgainst2 = "hre"
  107. ProperLinePosition = 15
  108. DontSkip = True
  109. WriteThings 'Runs code with previous Variables
  110.  
  111. CheckAgainst = "is_city ="
  112. CheckAgainst2 = "is_city"
  113. ProperLinePosition = 17
  114. DontSkip = True
  115. WriteThings 'Runs code with previous Variables
  116.  
  117. CheckAgainst = "owner ="
  118. CheckAgainst2 = "owner"
  119. ProperLinePosition = 18
  120. DontSkip = True
  121. WriteThings 'Runs code with previous Variables
  122.  
  123. CheckAgainst = "controller ="
  124. CheckAgainst2 = "controller"
  125. ProperLinePosition = 19
  126. DontSkip = True
  127. WriteThings 'Runs code with previous Variables
  128.  
  129. CheckAgainst = "add_core ="
  130. CheckAgainst2 = "add_core"
  131. ProperLinePosition = 21
  132. DontSkip = True
  133. WriteThings 'Runs code with previous Variables
  134.  
  135. CheckAgainst = "base_tax ="
  136. CheckAgainst2 = "base_tax"
  137. ProperLinePosition = 23
  138. DontSkip = True
  139. WriteThings 'Runs code with previous Variables
  140.  
  141. CheckAgainst = "base_production ="
  142. CheckAgainst2 = "base_production"
  143. ProperLinePosition = 24
  144. DontSkip = True
  145. WriteThings 'Runs code with previous Variables
  146.  
  147. CheckAgainst = "base_manpower ="
  148. CheckAgainst2 = "base_manpower"
  149. ProperLinePosition = 25
  150. DontSkip = True
  151. WriteThings 'Runs code with previous Variables
  152.  
  153. CheckAgainst = "trade_goods ="
  154. CheckAgainst2 = "trade_goods"
  155. ProperLinePosition = 30
  156. DontSkip = True
  157. WriteThings 'Runs code with previous Variables
  158.  
  159. 'CheckAgainst = "latent_trade_goods ="
  160. 'CheckAgainst2 = "latent_trade_goods"
  161. 'ProperLinePosition = 31
  162. 'DontSkip = True
  163. 'WriteThings 'Runs code with previous Variables
  164.  
  165. End If
  166.  
  167. Loop
  168.  
  169. Close #1
  170.  
  171. End Sub
  172.  
  173. Sub WriteThings()
  174.  
  175.  
  176. If InStr(InformationText, CheckAgainst) <> 0 Then
  177. ConvertedInformation = InformationText
  178. RemoveCodeSign = Worksheets("ConvertedInfo").Cells(1, 1)
  179. RemoveCheckAgainst = (CheckAgainst & " ")
  180. ConvertedInformation = Replace(ConvertedInformation, RemoveCheckAgainst, "")
  181. ConvertedInformation = Replace(ConvertedInformation, Chr(34), "")
  182. Worksheets("ConvertedInfo").Cells(OtherNumber, ProperLinePosition).Value = ConvertedInformation
  183. 'MsgBox InformationText
  184. ElseIf InStr(InformationText, CheckAgainst2) <> 0 Then 'SPECIAL FIX FOR LANDSHUT
  185. ConvertedInformation = InformationText
  186. RemoveCodeSign = Worksheets("ConvertedInfo").Cells(1, 1)
  187. ConvertedInformation = Replace(ConvertedInformation, CheckAgainst2, "")
  188. If DontSkip = True Then
  189. ConvertedInformation = Replace(ConvertedInformation, vbTab, "")
  190. End If
  191. ConvertedInformation = Replace(ConvertedInformation, "= ", "")
  192. ConvertedInformation = Replace(ConvertedInformation, Chr(34), "")
  193. Worksheets("ConvertedInfo").Cells(OtherNumber, ProperLinePosition).Value = ConvertedInformation
  194. 'MsgBox InformationText
  195. End If
  196.  
  197. End Sub
  198.  
  199. Sub Number2Letter()
  200.  
  201. 'Convert To Column Letter
  202. If OtherNumber = 0 Then
  203. Else
  204. NumberToLetter = Split(Cells(1, OtherNumber).Address, "$")(1)
  205. End If
  206.  
  207. 'MsgBox NumberToLetter
  208.  
  209. 'DEBUG
  210. 'MsgBox "Column " & ColumnNumber & " = Column " & PasteRangeColumn
  211.  
  212. End Sub
  213.  
  214. Sub Testing5()
  215.  
  216. Cells(2, 1).Value = Chr(34)
  217.  
  218. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement