Hello,
I have to migrate a very old excel file with many macros from Office 2010 to Office 365 (Office 2010 being no longer supported). The Excel file works perfectly on Office 2010.
When I run the VBA compiler, I get the following error message: Compile error Variable not defined
Here is the code: The issue highlighted by the VBA editor is:
How can the code be amended to be supported by O365?
Thank you!
I have to migrate a very old excel file with many macros from Office 2010 to Office 365 (Office 2010 being no longer supported). The Excel file works perfectly on Office 2010.
When I run the VBA compiler, I get the following error message: Compile error Variable not defined
Here is the code: The issue highlighted by the VBA editor is:
VBA Code:
If strRec = SP_KUGIRI Then
How can the code be amended to be supported by O365?
VBA Code:
Sub GetStorePlanFile(ByVal strFilePath As String, ByRef arrDataHeader As Variant, ByRef arrDataDetail As Variant)
Dim fso As Object
Dim ffile As Object
Dim csvDataLine As Variant
Dim lngHeaderCntC As Long
Dim lngDetailCntC As Long
Dim i As Long, j As Long
Dim bDetailFlg As Boolean
Dim intFree As Long
Dim strRec As String
Dim colHeader As Collection
Dim colDetail As Collection
Set colHeader = New Collection
Set colDetail = New Collection
bDetailFlg = False
intFree = FreeFile
Set fso = CreateObject("Scripting.FileSystemObject")
Open strFilePath For Input As #intFree
Do Until EOF(intFree)
Line Input #intFree, strRec
If strRec = SP_KUGIRI Then
bDetailFlg = True
i = 0
Else
If bDetailFlg Then
colDetail.Add (strRec)
Else
colHeader.Add (strRec)
End If
End If
Loop
Close #intFree
Dim oneLineH As Variant
Dim oneLineD As Variant
oneLineH = Split(colHeader.Item(1), ",")
oneLineD = Split(colDetail.Item(1), ",")
lngHeaderCntC = UBound(oneLineH) + 1
lngDetailCntC = UBound(oneLineD) + 1
ReDim arrDataHeader(colHeader.Count, lngHeaderCntC)
ReDim arrDataDetail(colDetail.Count, lngDetailCntC)
Dim ch As Variant
Dim cd As Variant
j = 1
For Each ch In colHeader
csvDataLine = Split(ch, ",")
For i = 1 To lngHeaderCntC
arrDataHeader(j, i - 1) = csvDataLine(i - 1)
Next
j = j + 1
Next
j = 1
For Each cd In colDetail
csvDataLine = Split(cd, ",")
For i = 1 To lngDetailCntC
arrDataDetail(j, i - 1) = csvDataLine(i - 1)
Next
j = j + 1
Next
Set colHeader = Nothing
Set colDetail = Nothing
End Sub
Thank you!