@@ -1100,6 +1100,7 @@ Private Sub ImportVbComponent(ByRef CodeLibInf As CodeLibInfo, ByRef ImportFile
1100
1100
End If
1101
1101
1102
1102
If CodeModuleExists Then ' Change content via CodeModule so that MS add-in for source code management does not cause trouble
1103
+ ' TODO: check if invisible properties changed
1103
1104
Set cm = vbc.CodeModule
1104
1105
cm.DeleteLines 1 , cm.CountOfLines
1105
1106
cm.AddFromFile ImportFile.Path
@@ -1117,7 +1118,7 @@ Private Sub ImportVbComponent(ByRef CodeLibInf As CodeLibInfo, ByRef ImportFile
1117
1118
Loop
1118
1119
1119
1120
Else
1120
- VbcCol.import ImportFile.Path
1121
+ VbcCol.Import ImportFile.Path
1121
1122
End If
1122
1123
1123
1124
End Sub
@@ -1372,15 +1373,9 @@ Private Sub GetCodeLibInfoFromFile(ByRef CodeLibInf As CodeLibInfo, ByVal InputF
1372
1373
Dim CheckString As String
1373
1374
Dim TempString As String
1374
1375
Dim i As Long
1375
- Dim FileNumber As Long
1376
1376
Dim StringCutPos As Long
1377
1377
1378
- FileNumber = FreeFile
1379
-
1380
- Open InputFile.Path For Binary Access Read As FileNumber
1381
- CheckString = String $(LOF(FileNumber), 0 )
1382
- Get FileNumber, , CheckString
1383
- Close FileNumber
1378
+ CheckString = ReadSourceFile(InputFile)
1384
1379
1385
1380
'Determine names
1386
1381
CodeLibInf.Name = FindSubString(CheckString, SEARCHSTRING_ATTRIBUTNAME_BEGIN, SEARCHSTRING_ATTRIBUTNAME_END, Pos)
@@ -1462,6 +1457,61 @@ Private Sub GetCodeLibInfoFromFile(ByRef CodeLibInf As CodeLibInfo, ByVal InputF
1462
1457
1463
1458
End Sub
1464
1459
1460
+ Private Function ReadSourceFile (ByVal InputFile As Object ) As String
1461
+
1462
+ Dim FileNumber As Long
1463
+ Dim StringCutPos As Long
1464
+ Dim CheckString As String
1465
+
1466
+ Dim CheckBytes(1 To 3 ) As Byte
1467
+ Dim FileCharset As String
1468
+
1469
+ FileNumber = FreeFile
1470
+
1471
+ Open InputFile.Path For Binary Access Read As FileNumber
1472
+
1473
+ If LOF(FileNumber) >= 3 Then
1474
+
1475
+ Get #FileNumber, , CheckBytes
1476
+
1477
+ If CheckBytes(1 ) = &HEF And CheckBytes(2 ) = &HBB And CheckBytes(3 ) = &HBF Then
1478
+ FileCharset = "utf-8"
1479
+ ElseIf (CheckBytes(1 ) = &HFF And CheckBytes(2 ) = &HFE ) Or (CheckBytes(1 ) = &HFE And CheckBytes(2 ) = &HFF ) Then
1480
+ FileCharset = "utf-16"
1481
+ Else
1482
+ Seek #FileNumber, 1
1483
+ CheckString = String $(LOF(FileNumber), 0 )
1484
+ Get #FileNumber, , CheckString
1485
+ End If
1486
+
1487
+ End If
1488
+
1489
+ Close FileNumber
1490
+
1491
+ If Len(FileCharset) > 0 Then
1492
+ CheckString = ReadUtfFileToString(InputFile, FileCharset)
1493
+ End If
1494
+
1495
+ ReadSourceFile = CheckString
1496
+
1497
+ End Function
1498
+
1499
+ Function ReadUtfFileToString (ByVal InputFile As Object , ByVal FileCharset As String ) As String
1500
+
1501
+ Dim Stream As Object ' Late Binding für ADODB.Stream
1502
+ Set Stream = CreateObject("ADODB.Stream" )
1503
+
1504
+ With Stream
1505
+ .Type = 2 ' Text
1506
+ .Charset = FileCharset
1507
+ .Open
1508
+ .LoadFromFile InputFile.Path
1509
+ ReadUtfFileToString = .ReadText
1510
+ .Close
1511
+ End With
1512
+
1513
+ End Function
1514
+
1465
1515
Private Sub GetCodeLibInfoPackage (ByRef CodeLibInf As CodeLibInfo , ByRef SourceString As String )
1466
1516
Dim PackageName As String
1467
1517
PackageName = Trim(FindSubString(SourceString, SEARCHSTRING_PACKAGE_BEGIN, SEARCHSTRING_PACKAGE_END))
0 commit comments