You are on page 1of 2

vidyalankaar class notes

Option Explicit

'globale Variablen
Public strProjekt As String
Public strProgram As String

Sub Compile_DB()
Dim strFileName As String
Dim strQuellName As String
Dim s7objSource As Object
Dim s7objBlocks As Object
Dim s7objCont As Object
Dim dlg As New dlgProjekt

On Error Resume Next

Application.ScreenUpdating = False

If Check_All Then
If Worksheets("DB").Cells(1, 3) <> "" Then
dlg.Show
If (strProgram <> "") And (strProjekt <> "") Then
strFileName = g_objFst.GetTempName
strFileName = Mid(strFileName, 1, Len(strFileName) - 4) & ".awl"
Write_DB_In_File strFileName
strQuellName = "DB" & Worksheets("DB").Cells(1, 3)

For Each s7objCont In g_S7ObjSimatic.Projects(strProjekt). _


Programs(strProgram).Next
If s7objCont.ConcreteType = 1122308 Then 'S7SourceContainer
Set s7objSource = s7objCont.Next.Add(strQuellName, 1122309,
strFileName) '1122309 == S7Source
If CatchError Then
MsgBox "Source file not imported !"
Else
Set s7objBlocks = s7objSource.Compile
If CatchError Then
MsgBox "DB not compiled !"
Else
If s7objBlocks.Count = 0 Then
MsgBox "DB not compiled !"
End If
End If
Set s7objBlocks = Nothing
End If
Set s7objSource = Nothing
End If
Next s7objCont
g_objFst.DeleteFile strFileName, True
End If
Else
MsgBox "DB-Number is missing"
Worksheets("DB").Cells(1, 3).Select
End If
Else
MsgBox "Source file not created !"
End If

Application.ScreenUpdating = True

End Sub

You might also like