Submarine Reporter for Excel 2010 BETA 1.3 UPDATED 10/28/2011

Post bug reports and ask for help with other issues here.

Moderators: wdolson, MOD_War-in-the-Pacific-Admirals-Edition

User avatar
rcm1616
Posts: 30
Joined: Wed Aug 05, 2009 3:51 am
Location: Bratislava, Slovakia, EU

Submarine Reporter for Excel 2010 BETA 1.3 UPDATED 10/28/2011

Post by rcm1616 »

Submarine Reporter for Excel 2010
*******************************************************************************************************************
Update 10/28/11
Version BETA 1.3 - another update from Bruce (bk19@mweb.co.za)

*******************************************************************************************************************
Update 10/14/11
Version BETA 1.2a - massive update from bk19@mweb.co.za
FIXED most of data importing related problems

*******************************************************************************************************************

Update 10/13/11
Last time I have uploaded wrong file. (SAME VERSION AS BEFORE) [:(]
Now you can download real version BETA1.1a ...


*******************************************************************************************************************

Update 10/10/11

Changes in version BETA1.1a (10/10/2011)

1. failure of DB import on platforms where WITP AE was installed on other then c: drive
FIXED - thanks to bk19@mweb.co.za

2. DATE format bug on US/UK Excel localisation
FIXED - thanks to bk19@mweb.co.za

3. all bugs in BAT file execution
FIXED - thanks to bk19@mweb.co.za

4. unable to import combat record where ship name in combat report is without class type prefix (example APD -107 instead APD APD -107)
script which write new record to Combat Reports table is unable to found long name match in ShipsDB
FIXED - class type name is no more added in front of ship name in case that ship name is number


*******************************************************************************************************************



I have developed MS Excel 2010 tool for parsing submarine combat records data from combat and operational reports.
This is strictly Excel2010 worksheet. I had never tested it on older version. It is first BETA version.
Your feedback will be welcomed.


Features:
- load and parse Sub Attack, Sub vs Sub, and ASW type records from combatreport file and save it to excel table
(only records where some damage on side of Target was reported - in case of ASW only records where submarine strikes back)

- append ship (target) tonnage, ship nationality and submarine nationality to records

- load and parse SUNK ship report and FALSELY REPORTED SUNK report types from operationsreport file

- generate reports (pivot tables) monthly tonnage (sunk/damaged) and Submarine top scoring list

This is strictly Excel2010 worksheet. I had never tested it on older version.


Configuration instructions:

Configuration Sheet:

Settings:
1.
WITP AE Path - path to WITP AE Game folder - to point import scripts to combatreport.txt a Xoperationsreport.txt files
2.
TMP File Path - path to any folder which can be used as temporary storage for small auxillary text file - do not need copy any game files there
3.
Import from and Import to date - values must be correctly in date format ( example: from: 7.12.1941 to 31.12.1941 or from 7/12/41 to 31/12/41)
Values are used for batch importing combat reports from [WITP AE Path]\SAVE\archive (combatreport_YYMMDD.txt and Xoperationsreport_YYMMDD.txt files)
4.
Scenario # - number of scenario from which ship data will be imported

Buttons:
1.
Database import - will import ship database from scenario files. Script use witploadAE utilitz to extract data from scenario to .csv files and then import data do Submarine Reporter. It is critical to wait until witploadae exports all files and then click OK button on messagebox to continue.
2.
Import record - will process last saved combat and operations reports from \SAVE folder
3.
Import archive records - will process reports from \SAVE\archive folder within selected range

Combat Reports Sheet:
Main database sheet - all submarine scoring records are stored here
Values in Sunk column:
DAMAGED - initial value (only combat records where sub commander reports damage of enemy ship are stored)
SUNK - sunk confirmed in operations report
FR SUNK - changed after reporting incorrect previous sunk report in operations report

MONTHS:
pivot tables with filters

AUX:
Values in nationality can be changed.

Download:


Attachments
SubmarineR..rter_B13.zip
(543.13 KiB) Downloaded 158 times
Grimasa
User avatar
cantona2
Posts: 3749
Joined: Mon May 21, 2007 2:45 pm
Location: Gibraltar

RE: Submarine Reporter for Excel 2010 BETA

Post by cantona2 »

I cant get this to work at all rcm1616

Do i need witpaeload running before I can use it? I use Tracker not witpaeload.
What happens if i have several games running from the same Save folder?
1966 was a great year for English Football...Eric was born

User avatar
rcm1616
Posts: 30
Joined: Wed Aug 05, 2009 3:51 am
Location: Bratislava, Slovakia, EU

RE: Submarine Reporter for Excel 2010 BETA

Post by rcm1616 »

ORIGINAL: cantona2

I cant get this to work at all rcm1616

Do i need witpaeload running before I can use it? I use Tracker not witpaeload.
What happens if i have several games running from the same Save folder?

No you do not. SR runs witploadae automatically after you click on"Database Import Button.

You may see something like this:


Image



No tests with several games yet. But SR opens only files named combatreport.txt, aoperationsreport.txt and joperationsreport.txt from \SAVE folder.
Attachments
witploadae.jpg
witploadae.jpg (188.14 KiB) Viewed 780 times
Grimasa
User avatar
cantona2
Posts: 3749
Joined: Mon May 21, 2007 2:45 pm
Location: Gibraltar

RE: Submarine Reporter for Excel 2010 BETA

Post by cantona2 »

I see all that but i get an error saying the programme cannot find wtipcls001.csv in the scenario folder
1966 was a great year for English Football...Eric was born

User avatar
Dan Nichols
Posts: 863
Joined: Mon Aug 29, 2011 11:32 pm

RE: Submarine Reporter for Excel 2010 BETA

Post by Dan Nichols »

I didn't see the cmd window. I got a working icon for 3-4 minutes and then when I tried to see the data I got an error saying the program connot find wticls002.csv. I looked and there are no csv files in my scen folder.
I think that the two obligations you have are to be good at what you do and then to pass on your knowledge to a younger person
User avatar
rcm1616
Posts: 30
Joined: Wed Aug 05, 2009 3:51 am
Location: Bratislava, Slovakia, EU

RE: Submarine Reporter for Excel 2010 BETA

Post by rcm1616 »

ORIGINAL: cantona2

I see all that but i get an error saying the programme cannot find wtipcls001.csv in the scenario folder

And is there file with this name?
Is your WITP AE Path set correctly? - with no \ at end of line

If you click Debug on error message on which line of code program stops?

Grimasa
User avatar
rcm1616
Posts: 30
Joined: Wed Aug 05, 2009 3:51 am
Location: Bratislava, Slovakia, EU

RE: Submarine Reporter for Excel 2010 BETA

Post by rcm1616 »

ORIGINAL: Dan Nichols

I didn't see the cmd window. I got a working icon for 3-4 minutes and then when I tried to see the data I got an error saying the program connot find wticls002.csv. I looked and there are no csv files in my scen folder.

Check if you have witploadae.exe in your SCEN folder. I use updated witploadae from BETA version.
Grimasa
User avatar
cantona2
Posts: 3749
Joined: Mon May 21, 2007 2:45 pm
Location: Gibraltar

RE: Submarine Reporter for Excel 2010 BETA

Post by cantona2 »

'' Èo treba dorobi?:
''
''  - kontrolu èi nechcem importova? už naimportované dáta
''
''

''
''
''
''
''



Dim WITPAEPath, TMPPath, BATPath As String
Dim ActionDate As Date
Dim ImportFromDate, ImportToDate As Date
Dim ScenNo, Side As String


Sub MakeBAT()
Dim fs, f
Dim Line As String

    Line = "witploadAE.exe" & "/s" & ScenNo & " /e /b,"

    Set fs = CreateObject("Scripting.FileSystemObject")
    Set f = fs.OpenTextFile(BATPath, 8, True, 0)

    f.Writeline ("c:")
    f.Writeline ("cd " + WITPAEPath + "\SCEN")
    f.Writeline (Line)
    f.Close

End Sub

Sub DelBAT()
Dim fs, f

    Set fs = CreateObject("Scripting.FileSystemObject")
    fs.DeleteFile BATPath


End Sub
Sub DeleteSheet(strSheetName As String)
' deletes a sheet named strSheetName in the active workbook
    Application.DisplayAlerts = False
    Sheets(strSheetName).Delete
    Application.DisplayAlerts = True
End Sub

Sub ImportDataWorksheets()
Dim LastRow As Double
Dim FileName, BookName, SheetName As String
Dim MyBookName As String
    
    ''DeleteSheet ("Classes")
    ''DeleteSheet ("Ships")
       
    SheetName = "witpcls" + ScenNo
    BookName = SheetName + ".csv"
    FileName = WITPAEPath + "\SCEN\" + BookName
    MyBookName = ActiveWorkbook.Name
   
   
    Workbooks.Open (FileName), , , 2
    Workbooks(BookName).Sheets(1).Copy _
         After:=Workbooks(MyBookName).Sheets("AUX")

    Workbooks(BookName).Close SaveChanges:=False
    Worksheets(SheetName).Name = "Classes"

    SheetName = "witpshp" + ScenNo
    BookName = SheetName + ".csv"
    FileName = WITPAEPath + "\SCEN\" + SheetName
   
   
    Workbooks.Open (FileName), , , 2
    Workbooks(BookName).Sheets(1).Copy _
         After:=Workbooks(MyBookName).Sheets("AUX")
        
    Workbooks(BookName).Close SaveChanges:=False
    Worksheets(SheetName).Name = "Ships"
   
    Call PrepareShipsDB
    DeleteSheet ("Classes")
    DeleteSheet ("Ships")
   
End Sub

Sub PrepareShipsDB()
Dim MyWrkSht As Worksheet
Dim MyRange As Range
Dim i, j, LastRow, LastRowClasses As Double
Dim s As String
Dim MyVarA, MyVarB


' Clear all Cells in ShipsDB to prepare sheet to new data
LastRow = GetLastRow("ShipsDB")
s = "A2:" & "K" & CStr(LastRow)
Set MyWrkSht = ActiveWorkbook.Worksheets("ShipsDB")
Set MyRange = MyWrkSht.Range(s)
MyRange.ClearContents

LastRowClasses = GetLastRow("Classes")
LastRow = GetLastRow("Ships")
i = 2
j = 2

Do While i <= LastRow
&nbsp;&nbsp;&nbsp; If ActiveWorkbook.Worksheets("Ships").Cells(i, 3) <> 0 Then
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; '' SHIP ID
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MyWrkSht.Cells(j, 1).Value = ActiveWorkbook.Worksheets("Ships").Cells(i, 1)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; '' SHIP NAME
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MyWrkSht.Cells(j, 2).Value = ActiveWorkbook.Worksheets("Ships").Cells(i, 2)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; '' CLASS ID
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MyWrkSht.Cells(j, 3).Value = ActiveWorkbook.Worksheets("Ships").Cells(i, 3)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; '' NATIONALITY ID
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MyWrkSht.Cells(j, 4).Value = ActiveWorkbook.Worksheets("Ships").Cells(i, 15)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; '' NATIONALITY
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MyVarA = Application.WorksheetFunction.Match(MyWrkSht.Cells(j, 4).Value, Worksheets("AUX").Range("D2:D19"))
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MyVarB = Application.WorksheetFunction.HLookup("Nationality", Worksheets("AUX").Range("E2:E19"), MyVarA)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MyWrkSht.Cells(j, 5).Value = MyVarB
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; '' Type ID
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; s = "A2:A" & CStr(LastRowClasses)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MyVarA = Application.WorksheetFunction.Match(MyWrkSht.Cells(j, 3).Value, Worksheets("Classes").Range(s))
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MyWrkSht.Cells(j, 6).Value = ActiveWorkbook.Worksheets("Classes").Cells(MyVarA + 1, 3).Value
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; '' Type
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MyVarA = Application.WorksheetFunction.Match(MyWrkSht.Cells(j, 6).Value, Worksheets("AUX").Range("A2:A84"))
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MyVarB = Application.WorksheetFunction.HLookup("Type", Worksheets("AUX").Range("B2:B84"), MyVarA)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MyWrkSht.Cells(j, 7).Value = MyVarB
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; '' Full Name
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; s = MyWrkSht.Cells(j, 7).Value & " " & MyWrkSht.Cells(j, 2).Value
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MyWrkSht.Cells(j, 8).Value = s
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; '' Tonnage
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; s = "A2:A" & CStr(LastRowClasses)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MyVarA = Application.WorksheetFunction.Match(MyWrkSht.Cells(j, 3).Value, Worksheets("Classes").Range(s))
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MyWrkSht.Cells(j, 9).Value = ActiveWorkbook.Worksheets("Classes").Cells(MyVarA + 1, 22).Value
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; j = j + 1
&nbsp;&nbsp;&nbsp; End If
&nbsp;&nbsp;&nbsp; i = i + 1
Loop

''MyWrkSht.Range(s).FormatConditions


Set MyRange = Nothing
Set MyWrkSht = Nothing

End Sub



Sub LoadConfig()


&nbsp;&nbsp;&nbsp; WITPAEPath = Worksheets("Configuration").Cells(3, 3).Value
&nbsp;&nbsp;&nbsp; TMPPath = Worksheets("Configuration").Cells(4, 3).Value + "\RCMTMP.txt"
&nbsp;&nbsp;&nbsp; BATPath = Worksheets("Configuration").Cells(3, 3).Value + "\SCEN\DUMPSCEN.bat"
&nbsp;&nbsp;&nbsp; ImportFromDate = Worksheets("Configuration").Cells(5, 3).Value
&nbsp;&nbsp;&nbsp; ImportToDate = Worksheets("Configuration").Cells(6, 3).Value
&nbsp;&nbsp;&nbsp; ScenNo = Worksheets("Configuration").Cells(7, 3).Value
&nbsp;&nbsp;&nbsp; Side = Worksheets("Configuration").Cells(8, 3).Value

End Sub

Sub LoadDB()
Dim RetVar
Dim ImWrkSht As Worksheet
Dim ImRange As Range
Dim MsgBoxResponse As String


&nbsp;&nbsp;&nbsp; LoadConfig
&nbsp;&nbsp;&nbsp; MakeBAT
&nbsp;&nbsp;&nbsp; RetVar = Shell(BATPath, vbNormalFocus)
&nbsp;&nbsp;&nbsp; MsgBoxResponse = MsgBox("Wait for dumping end, then press OK", vbOKOnly)
&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp; DelBAT
&nbsp;&nbsp;&nbsp; ImportDataWorksheets

&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;

End Sub
Function GetLastRow(WrkShtName As String) As Double

Dim MyWrkSht As Worksheet
Dim MyRange As Range

&nbsp;&nbsp;&nbsp; Set MyWrkSht = ActiveWorkbook.Worksheets(WrkShtName)
&nbsp;&nbsp;&nbsp; Set MyRange = MyWrkSht.UsedRange

&nbsp;&nbsp;&nbsp; GetLastRow = MyRange.Cells.Find(What:="*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row

&nbsp;&nbsp;&nbsp; Set MyRange = Nothing
&nbsp;&nbsp;&nbsp; Set MyWrkSht = Nothing

End Function

Sub ImportReport()
Dim Path As String

&nbsp;&nbsp;&nbsp; LoadConfig
&nbsp;&nbsp;&nbsp; Path = WITPAEPath + "\SAVE\combatreport2.txt"
&nbsp;&nbsp;&nbsp; OpenCombatReport (Path)
&nbsp;&nbsp;&nbsp; Path = WITPAEPath + "\SAVE\" & Side & "operationsreport2.txt"
&nbsp;&nbsp;&nbsp; OpenOperationsReport (Path)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp; Call RemoveDuplicates
&nbsp;&nbsp;&nbsp; Call RefreshPivotTables
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
End Sub
Sub RemoveDuplicates()
Dim MyWrkSht As Worksheet
Dim MyRange As Range
Dim a

&nbsp;&nbsp;&nbsp; Set MyWrkSht = ActiveWorkbook.Worksheets("Combat Reports")
&nbsp;&nbsp;&nbsp; Set MyRange = MyWrkSht.UsedRange
&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp; MyRange.RemoveDuplicates Columns:=Array(1, 2, 3, 4, 5, 6, 7), Header:=xlYes
&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp; Set MyRange = Nothing
&nbsp;&nbsp;&nbsp; Set MyWrkSht = Nothing
End Sub
Sub RefreshPivotTables()
Dim s As String
Dim LastRow As Double


&nbsp;&nbsp;&nbsp; LastRow = GetLastRow("Combat Reports")
&nbsp;&nbsp;&nbsp; s = "Combat Reports!R1C1:R" & CStr(LastRow) & "C7"


&nbsp;&nbsp;&nbsp; ActiveWorkbook.Worksheets("MONTHS").PivotTables("MonthReview").SourceData = s
&nbsp;&nbsp;&nbsp; ActiveWorkbook.Worksheets("MONTHS").PivotTables("SubmarineReview").SourceData = s
&nbsp;&nbsp;&nbsp; ActiveWorkbook.Worksheets("MONTHS").PivotTables("MonthReview").RefreshTable
&nbsp;&nbsp;&nbsp; ActiveWorkbook.Worksheets("MONTHS").PivotTables("SubmarineReview").RefreshTable

End Sub
Sub OpenOperationsReport(ORPath As String)
Dim fs, f
Dim LastRow As Double
Dim ShipName As String
Dim SunkDate As Date
Dim MyLine
Dim s As String
Dim MyWrkSht As Worksheet
Dim MyRange As Range
&nbsp;&nbsp;&nbsp;
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.OpenTextFile(ORPath, 1, 0)
MyLine = ""

Set MyWrkSht = ActiveWorkbook.Worksheets("Combat Reports")

Set MyRange = MyWrkSht.UsedRange
LastRow = GetLastRow("Combat Reports")

Do While f.AtEndOfStream = False
&nbsp;&nbsp;&nbsp; MyLine = f.Readline
&nbsp;&nbsp;&nbsp; If InStr(1, MyLine, "reported to have been sunk", vbTextCompare) > 0 Then
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ShipName = GetSunkShipName(MyLine)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SunkDate = GetSunkShipDate(MyLine)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Set MyRange = MyWrkSht.Rows(1)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; i = 2
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Do While i <= LastRow
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; If MyWrkSht.Cells(i, 1).Value = SunkDate Then
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; If MyWrkSht.Cells(i, 4).Value = ShipName Then
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MyWrkSht.Cells(i, 6).Value = "SUNK"
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; i = LastRow
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; End If
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; End If
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; i = i + 1
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Loop
&nbsp;&nbsp;&nbsp; End If
&nbsp;&nbsp;&nbsp; If InStr(1, MyLine, "Previous report of sinking", vbTextCompare) > 0 Then
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ShipName = GetFalseReportedShipName(MyLine)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ''SunkDate = GetSunkShipDate(MyLine)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Set MyRange = MyWrkSht.Rows(1)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; i = LastRow
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Do While (MyWrkSht.Cells(i, 4).Value <> ShipName) And (i > 1)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; i = i - 1
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Loop
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; If MyWrkSht.Cells(i, 4).Value = ShipName Then MyWrkSht.Cells(i, 6).Value = "FR SUNK"
&nbsp;&nbsp;&nbsp; End If
Loop

f.Close
End Sub

Function GetSunkShipName(MyLine) As String
Dim i As Long

&nbsp;&nbsp;&nbsp; i = InStr(1, MyLine, "is reported", vbTextCompare) - 2
&nbsp;&nbsp;&nbsp; GetSunkShipName = Left(MyLine, i)

End Function
Function GetShipShortName(LongShipName As String) As String

Dim i As Double
&nbsp;&nbsp;&nbsp; i = InStr(LongShipName, " ")
&nbsp;&nbsp;&nbsp; GetShipShortName = Right(LongShipName, Len(LongShipName) - i)
End Function


Function GetFalseReportedShipName(MyLine) As String
Dim i, j As Long
Dim s As String

&nbsp;&nbsp;&nbsp; i = InStr(1, MyLine, "of sinking of", vbTextCompare) + 13
&nbsp;&nbsp;&nbsp; j = Len(MyLine)
&nbsp;&nbsp;&nbsp; s = Right(MyLine, j - i)
&nbsp;&nbsp;&nbsp; i = InStr(1, s, "incorrect", vbTextCompare) - 2
&nbsp;&nbsp;&nbsp; GetFalseReportedShipName = Left(s, i)
End Function

Function GetSunkShipDate(ShipLine) As Date
Dim sDate As String
Dim s, sDay, sMonth, sYear As String

&nbsp;&nbsp;&nbsp; sDate = Right(ShipLine, 12)
&nbsp;&nbsp;&nbsp; sYear = Right(sDate, 4)
&nbsp;&nbsp;&nbsp; sDay = Mid(sDate, 5, 2)
&nbsp;&nbsp;&nbsp; sMonth = GetMonth(Left(sDate, 3))
&nbsp;&nbsp;&nbsp; s = sDay + "." + sMonth + "." + sYear
&nbsp;&nbsp;&nbsp; GetSunkShipDate = DateValue(s)

End Function


Sub ImportArchiveReports()
Dim ArchivePath, Path As String
Dim m As Integer
Dim YY, MM, DD, s As String
Dim iDay As Date
&nbsp;&nbsp;&nbsp; LoadConfig
&nbsp;&nbsp;&nbsp; ArchivePath = Worksheets("Configuration").Cells(3, 3).Value + "\SAVE\archive"
&nbsp;&nbsp;&nbsp; iDay = ImportFromDate

&nbsp;&nbsp;&nbsp; '' Sem by mala ešte prís? kontrola, èi už reporty z daného dátumu neboli naimportované
&nbsp;&nbsp;&nbsp;


&nbsp;&nbsp;&nbsp; Do While iDay <= ImportToDate
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; DD = Day(iDay)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; If Len(DD) < 2 Then DD = "0" & DD
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m = Month(iDay)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; If m < 10 Then
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MM = "0" & CStr(m)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Else: MM = CStr(m)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; End If
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; YY = Year(iDay)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; YY = Right(YY, 2)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Path = ArchivePath + "\combatreport_" + CStr(YY) + CStr(MM) + CStr(DD) + ".txt"
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; If Dir(Path) <> "" Then OpenCombatReport (Path)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Path = ArchivePath & "\" & Side & "operationsreport_" + CStr(YY) + CStr(MM) + CStr(DD) + ".txt"
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; If Dir(Path) <> "" Then OpenOperationsReport (Path)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; iDay = iDay + 1
&nbsp;&nbsp;&nbsp; Loop
&nbsp;&nbsp;&nbsp; Call RemoveDuplicates
&nbsp;&nbsp;&nbsp; Call RefreshPivotTables

End Sub


Sub OpenCombatReport(ReportPath As String)
&nbsp;&nbsp;&nbsp; Const ForReading = 1, ForWriting = 2, ForAppending = 8
&nbsp;&nbsp;&nbsp; Dim tf, fs, f
&nbsp;&nbsp;&nbsp; Dim Path, Line As String
&nbsp;&nbsp;&nbsp; Dim i As Integer
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp; Set fs = CreateObject("Scripting.FileSystemObject")
&nbsp;&nbsp;&nbsp; Set f = fs.OpenTextFile(ReportPath, 1, 0)
&nbsp;&nbsp;&nbsp; Set tf = fs.OpenTextFile(TMPPath, 8, True, 0)

&nbsp;&nbsp;&nbsp; i = 1
&nbsp;&nbsp;&nbsp; ParserStream = ""
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp; Do While f.AtEndOfStream = False
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Line = f.Readline
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; If Line = "--------------------------------------------------------------------------------" Then
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ' call parser Sub with ParserStream argument
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; tf.Close
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ParseModule (TMPPath)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; fs.DeleteFile (TMPPath)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Set tf = fs.OpenTextFile(TMPPath, 8, True, 0)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Else
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; If IsNewDay(Line) Then ActionDate = GetDayDate(Line)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; tf.Writeline (Line)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; End If
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; i = i + 1
&nbsp;&nbsp;&nbsp; Loop
&nbsp;&nbsp;&nbsp; Worksheets("Configuration").Cells(10, 3).Value = ActionDate
&nbsp;&nbsp;&nbsp; f.Close
End Sub

Function IsNewDay(s As String) As Boolean

&nbsp;&nbsp;&nbsp; If Mid(s, 1, 12) = "AFTER ACTION" Then
&nbsp;&nbsp;&nbsp; IsNewDay = True
&nbsp;&nbsp;&nbsp; Else: IsNewDay = False
&nbsp;&nbsp;&nbsp; End If
&nbsp;&nbsp;&nbsp;
End Function

Function GetDayDate(DateLine As String) As Date
Dim LineL As Integer
Dim s, sMonth, sDay, sYear As String

&nbsp;&nbsp;&nbsp; LineL = Len(DateLine)
&nbsp;&nbsp;&nbsp; s = Mid(DateLine, LineL - 9, 10)
&nbsp;&nbsp;&nbsp; sMonth = GetMonth(Mid(s, 1, 3))
&nbsp;&nbsp;&nbsp; sDay = Mid(s, 5, 2)
&nbsp;&nbsp;&nbsp; sYear = Mid(s, 9, 2)
&nbsp;&nbsp;&nbsp; s = sDay + "." + sMonth + "." + "19" + sYear
&nbsp;&nbsp;&nbsp; GetDayDate = DateValue(s)

End Function

Sub ParseModule(TMPPath As String)

Dim Line, Ship As String
Dim fs, f
Dim arr
Dim s
Dim RowB, RowD As String

Dim JapArr(15) As String
Dim AllArr(15) As String
Dim i As Integer
Dim LastRow&
Dim isJapAttacker As Boolean

Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.OpenTextFile(TMPPath, 1, 0)
&nbsp;&nbsp;&nbsp; Line = f.Readline
&nbsp;&nbsp;&nbsp; i = 0
&nbsp;&nbsp;&nbsp; isJapAttacker = False
Select Case Mid(Line, 1, 3)
&nbsp;&nbsp;&nbsp; Case "Sub"
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ' Parse Ship Names from rcm_tmp.txt to JappArr and AllArr collections of ship names
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Do While f.AtEndOfStream = False
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Line = f.Readline
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; If InStr(Line, "Japanese Ships") > 0 Then
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Do Until Line = " "
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Line = f.Readline
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; arr = Split(Line, ",", , 1)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; If (UBound(arr) > 0 Or InStr(Line, "SS")) Then
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Ship = arr(0)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Ship = Mid(Ship, 7)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; JapArr(i) = Ship
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ' if Jap ship is SS then set isJapAttacker as true
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; If InStr(Line, "SS") Then isJapAttacker = True
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; i = i + 1
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; End If
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Loop
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; i = 0
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; End If
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; If InStr(Line, "Allied Ships") > 0 Then
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Do Until Line = " "
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Line = f.Readline
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; arr = Split(Line, ",", , 1)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; If (UBound(arr) > 0 Or InStr(Line, "SS")) Then
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Ship = arr(0)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Ship = Mid(Ship, 7)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; AllArr(i) = Ship
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ' if isJapAttacker is set as true (jap ship was SS) AND Allied ship is SS then if Allied ship is NOT damaged then isJapAttacker set to false
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; If isJapAttacker Then
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; If (UBound(arr) = 0 And InStr(Line, "SS")) Then isJapAttacker = False
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; End If
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; i = i + 1
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; End If
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Loop
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; End If
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Loop
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; If isJapAttacker Then
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; i = 0
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Do While AllArr(i) <> ""
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Call WriteCRRow(ActionDate, JapArr(0), AllArr(i))
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; i = i + 1
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Loop
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Else
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; i = 0
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Do While JapArr(i) <> ""
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Call WriteCRRow(ActionDate, AllArr(0), JapArr(i))
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; i = i + 1
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Loop
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; End If
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; isJapAttacker = False
&nbsp;&nbsp;&nbsp; Case "ASW"
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Do While f.AtEndOfStream = False
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Line = f.Readline
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; If InStr(Line, "Japanese Ships") > 0 Then
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Do Until Line = " "
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Line = f.Readline
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; arr = Split(Line, ",", , 1)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; If (UBound(arr) > 0 Or InStr(Line, "SS")) Then
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Ship = arr(0)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Ship = Mid(Ship, 7)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; JapArr(i) = Ship
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ' if Jap ship is SS then set isJapAttacker as true
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; If InStr(Line, "SS") Then isJapAttacker = True
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; i = i + 1
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; End If
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Loop
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; i = 0
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; End If
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; If InStr(Line, "Allied Ships") > 0 Then
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Do Until Line = " "
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Line = f.Readline
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; arr = Split(Line, ",", , 1)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; If (UBound(arr) > 0 Or InStr(Line, "SS")) Then
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Ship = arr(0)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Ship = Mid(Ship, 7)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; AllArr(i) = Ship
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ' if isJapAttacker is set as true (jap ship was SS) AND Allied ship is SS then if Allied ship is NOT damaged then isJapAttacker set to false
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; If isJapAttacker Then
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; If (UBound(arr) = 0 And InStr(Line, "SS")) Then isJapAttacker = False
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; End If
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; i = i + 1
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; End If
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Loop
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; End If
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Loop
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; If isJapAttacker Then
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; i = 0
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Do While AllArr(i) <> ""
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Call WriteCRRow(ActionDate, JapArr(0), AllArr(i))
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; i = i + 1
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Loop
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Else
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; i = 0
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Do While JapArr(i) <> ""
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Call WriteCRRow(ActionDate, AllArr(0), JapArr(i))
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; i = i + 1
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Loop
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; End If
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; isJapAttacker = False
&nbsp;&nbsp;&nbsp; Case Else
End Select


i = 0
f.Close
End Sub
Function GetMonth(ParsedDateString As String) As String

Select Case ParsedDateString

&nbsp;&nbsp;&nbsp; Case "Jan"
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; GetMonth = "01"
&nbsp;&nbsp;&nbsp; Case "Feb"
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; GetMonth = "02"
&nbsp;&nbsp;&nbsp; Case "Mar"
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; GetMonth = "03"
&nbsp;&nbsp;&nbsp; Case "Apr"
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; GetMonth = "04"
&nbsp;&nbsp;&nbsp; Case "May"
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; GetMonth = "05"
&nbsp;&nbsp;&nbsp; Case "Jun"
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; GetMonth = "06"
&nbsp;&nbsp;&nbsp; Case "Jul"
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; GetMonth = "07"
&nbsp;&nbsp;&nbsp; Case "Aug"
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; GetMonth = "08"
&nbsp;&nbsp;&nbsp; Case "Sep"
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; GetMonth = "09"
&nbsp;&nbsp;&nbsp; Case "Oct"
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; GetMonth = "10"
&nbsp;&nbsp;&nbsp; Case "Nov"
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; GetMonth = "11"
&nbsp;&nbsp;&nbsp; Case "Dec"
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; GetMonth = "12"
&nbsp;&nbsp;&nbsp; End Select

End Function

Private Sub WriteCRRow(RowA As Date, RowB As String, RowD As String)

Dim MyWrkSht As Worksheet
Dim MyRange As Range
Dim LastRow&, LastRowShipsDB
Dim s, ss As String
Dim MyVarA, i As Double
Dim err As Variant


Set MyWrkSht = ActiveWorkbook.Worksheets("Combat Reports")
Set MyRange = MyWrkSht.UsedRange

&nbsp;&nbsp;&nbsp; LastRow = MyRange.Cells.Find(What:="*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
&nbsp;&nbsp;&nbsp; LastRowShipsDB = GetLastRow("ShipsDB")
&nbsp;&nbsp;&nbsp; s = "H1:H" & CStr(LastRowShipsDB)
&nbsp;&nbsp;&nbsp; MyVarA = Application.WorksheetFunction.Match(RowB, Worksheets("ShipsDB").Range(s), 0)
&nbsp;&nbsp;&nbsp; i = ActiveWorkbook.Worksheets("ShipsDB").Cells(MyVarA, 4).Value
&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp; If (Side = "a" And i > 3) Or (Side = "j" And i < 3) Then
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; '' Date
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MyWrkSht.Cells(LastRow + 1, 1).Value = RowA
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; '' Long Submarine Name
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MyWrkSht.Cells(LastRow + 1, 2).Value = RowB
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; '' Submarine Nation
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MyWrkSht.Cells(LastRow + 1, 3).Value = ActiveWorkbook.Worksheets("ShipsDB").Cells(MyVarA, 5).Value
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; '' Long Victim Name
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MyWrkSht.Cells(LastRow + 1, 4).Value = RowD
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; '' Tonnage
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; '' if ship type is same MATCH then write tonnage
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; s = "H1:H" & CStr(LastRowShipsDB)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; err = Application.Match(RowD, Worksheets("ShipsDB").Range(s), 0)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; If IsError(err) Then
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; s = "B1:B" & CStr(LastRowShipsDB)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ss = GetShipShortName(RowD)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MyVarA = Application.Match(ss, Worksheets("ShipsDB").Range(s), 0)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MyWrkSht.Cells(LastRow + 1, 5).Value = ActiveWorkbook.Worksheets("ShipsDB").Cells(MyVarA, 9).Value
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; '' If ship type is diferent then lookup next short name match
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Else
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; s = "H1:H" & CStr(LastRowShipsDB)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MyVarA = Application.Match(RowD, Worksheets("ShipsDB").Range(s), 0)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MyWrkSht.Cells(LastRow + 1, 5).Value = ActiveWorkbook.Worksheets("ShipsDB").Cells(MyVarA, 9).Value

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; End If
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MyWrkSht.Cells(LastRow + 1, 6).Value = "DAMAGED"
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; If Len(Month(RowA)) < 2 Then
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ss = Year(RowA) & "/0" & Month(RowA)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Else: ss = Year(RowA) & "/" & Month(RowA)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; End If
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MyWrkSht.Cells(LastRow + 1, 7).Value = ss
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp; End If


Set MyRange = Nothing
Set MyWrkSht = Nothing

End Sub

Here is the debug dialouge
&nbsp;
1966 was a great year for English Football...Eric was born

User avatar
cantona2
Posts: 3749
Joined: Mon May 21, 2007 2:45 pm
Location: Gibraltar

RE: Submarine Reporter for Excel 2010 BETA

Post by cantona2 »

There is no file with that name in the scen folder of my AE install. I am running the latest official patch.
1966 was a great year for English Football...Eric was born

User avatar
rcm1616
Posts: 30
Joined: Wed Aug 05, 2009 3:51 am
Location: Bratislava, Slovakia, EU

RE: Submarine Reporter for Excel 2010 BETA

Post by rcm1616 »

MY MISTAKE!

I use witploadae version dated 24.7.2011. In this version is new export option /b which enables choosing other delimiter character then ";". Without this new feature I was not able to import data from csv file to excel correctly.

So witploadae.exe from BETA version of GAME must be in \SCEN folder.
Grimasa
User avatar
cantona2
Posts: 3749
Joined: Mon May 21, 2007 2:45 pm
Location: Gibraltar

RE: Submarine Reporter for Excel 2010 BETA

Post by cantona2 »

Do i just need the witploadae BETA or i need to upgrade to Beta patch fully?
1966 was a great year for English Football...Eric was born

User avatar
cantona2
Posts: 3749
Joined: Mon May 21, 2007 2:45 pm
Location: Gibraltar

RE: Submarine Reporter for Excel 2010 BETA

Post by cantona2 »

I have had a look in the Scen folders of both installs of AE I have and there are no CSV files in any of them!?!?!?!
1966 was a great year for English Football...Eric was born

User avatar
rcm1616
Posts: 30
Joined: Wed Aug 05, 2009 3:51 am
Location: Bratislava, Slovakia, EU

RE: Submarine Reporter for Excel 2010 BETA

Post by rcm1616 »

ORIGINAL: cantona2

Do i just need the witploadae BETA or i need to upgrade to Beta patch fully?

You just need to copy this file to SCEN folder. (and don't forget to rename or copy somewhere else old version)


Attachments
witploadAE.zip
(49.09 KiB) Downloaded 39 times
Grimasa
User avatar
Dan Nichols
Posts: 863
Joined: Mon Aug 29, 2011 11:32 pm

RE: Submarine Reporter for Excel 2010 BETA

Post by Dan Nichols »

Here is what the dumpscen.bat file looks like:

c:
cd D:\War in the Pacific Admiral's Edition\PBEM game vs obvert\SCEN
witploadAE.exe/s002 /e /b,


when I run it I get this:


D:\War in the Pacific Admiral's Edition\PBEM game vs obvert\SCEN>c:

C:\>cd D:\War in the Pacific Admiral's Edition\PBEM game vs obvert\SCEN

C:\>witploadAE.exe/s002 /e /b,
'witploadAE.exe' is not recognized as an internal or external command,
operable program or batch file.

C:\>pause
Press any key to continue . . .

I think you need to put " around the file name.
and you are not handling the case where we have the game
installed to a disk other than c:


I changed my dumpscen.bat file to this and it extracted the files

d:
cd "D:\War in the Pacific Admiral's Edition\PBEM game vs obvert\SCEN"
witploadAE.exe/s002 /e /b,
pause

It does work on my 2007 excel.
I think that the two obligations you have are to be good at what you do and then to pass on your knowledge to a younger person
User avatar
rcm1616
Posts: 30
Joined: Wed Aug 05, 2009 3:51 am
Location: Bratislava, Slovakia, EU

RE: Submarine Reporter for Excel 2010 BETA

Post by rcm1616 »

ORIGINAL: Dan Nichols

Here is what the dumpscen.bat file looks like:

c:
cd D:\War in the Pacific Admiral's Edition\PBEM game vs obvert\SCEN
witploadAE.exe/s002 /e /b,


when I run it I get this:


D:\War in the Pacific Admiral's Edition\PBEM game vs obvert\SCEN>c:

C:\>cd D:\War in the Pacific Admiral's Edition\PBEM game vs obvert\SCEN

C:\>witploadAE.exe/s002 /e /b,
'witploadAE.exe' is not recognized as an internal or external command,
operable program or batch file.

C:\>pause
Press any key to continue . . .

I think you need to put " around the file name.
and you are not handling the case where we have the game
installed to a disk other than c:


I changed my dumpscen.bat file to this and it extracted the files

d:
cd "D:\War in the Pacific Admiral's Edition\PBEM game vs obvert\SCEN"
witploadAE.exe/s002 /e /b,
pause

Yeah. It looks like bug. I must fix it in next version.

Many thanks Dan

Grimasa
User avatar
cantona2
Posts: 3749
Joined: Mon May 21, 2007 2:45 pm
Location: Gibraltar

RE: Submarine Reporter for Excel 2010 BETA

Post by cantona2 »

OK, tried it with new beta and dumping started but there are no changes to the excel sheet, it stays exactly the same, ie with the same data that i downloaded it with
1966 was a great year for English Football...Eric was born

User avatar
rcm1616
Posts: 30
Joined: Wed Aug 05, 2009 3:51 am
Location: Bratislava, Slovakia, EU

RE: Submarine Reporter for Excel 2010 BETA

Post by rcm1616 »

ORIGINAL: cantona2

OK, tried it with new beta and dumping started but there are no changes to the excel sheet, it stays exactly the same, ie with the same data that i downloaded it with

I left in ShipDB sheet data from scenario 1 in first version of file.
If you're importing scen 1 or 2, data in ShipDB must be same.

If you have version downloaded from Damien site you may have some forgotten data in Combat Reports sheet. Just delete all rows in Combat Reports sheet starting with second one (headings must stay intact)

Then you can import your own combatreports.
Grimasa
User avatar
SgtSwanson
Posts: 212
Joined: Sun May 15, 2005 12:36 am
Location: Long Branch, NJ

RE: Submarine Reporter for Excel 2010 BETA

Post by SgtSwanson »

This is NOT a hit on you rcm, just letting everyone else know that Excel Starter will not run the spreadsheet because macros are disabled with the free version that comes on most windows computers now.[:@][:@]
Sgt Swanson
87-93 5/502 Inf. Berlin Bde
93-95 2/502 Inf. 101st Airborne Div.
Freedom is never free!!

Patch of the Week: 6th Infantry Division
User avatar
Pascal_slith
Posts: 1657
Joined: Wed Aug 20, 2003 2:39 am
Location: In Arizona now!

RE: Submarine Reporter for Excel 2010 BETA

Post by Pascal_slith »

You're much better off developing this in Excel 2003. I've encountered few people that have 2007 or 2010 (and lots of complaints about the last two).
So much WitP and so little time to play.... :-(

Image
User avatar
rcm1616
Posts: 30
Joined: Wed Aug 05, 2009 3:51 am
Location: Bratislava, Slovakia, EU

RE: Submarine Reporter for Excel 2010 BETA

Post by rcm1616 »

ORIGINAL: SgtSwanson

This is NOT a hit on you rcm, just letting everyone else know that Excel Starter will not run the spreadsheet because macros are disabled with the free version that comes on most windows computers now.[:@][:@]

So it look like another reason to make version 2 on other (more platform independent) technology. My first plan was just make small reporting tool for myself. Sharing it with others came in second wave...

personal question: is 502nd IR in Berlin Brigade same 502nd regiment as in 101st Airborne? I never know, that Screaming Eagles had station in Berlin.
Grimasa
Post Reply

Return to “Tech Support”