nikki333
11-18-2018, 08:29 AM
Hi Folks
I'm using the MZ-Tools 8.0 Add-In, which allows for inserting line numbers throughout my Code. This works great, but has to be triggered manually each time I modify the code.
So, I attempted to automate this together with each time the project is compiled:
'Automatisches Kompilieren des Projekts (wird vor dem Speichern ausgeführt) (Nebenprozedur)
Sub subProjektAutomatischKompilieren()
On Error GoTo Fehlerbehandlung
'Excel Verhalten setzen
With Application: .ScreenUpdating = False: .EnableEvents = False: End With
'Lokale Variablen dimensionieren/speichern
Dim objVBEMenüBar As Object
Dim objKompilieren As Object
Set objVBEMenüBar = Application.VBE.CommandBars
'Projekt kompilieren falls Code verändert wurde
Set objKompilieren = objVBEMenüBar.FindControl(Type:=msoControlButton, ID:=578)
If objKompilieren.State = msoButtonUp Then
objKompilieren.Execute
' Set objKompilieren = objVBEMenüBar.FindControl(Type:=msoControlButton, Tag:="AddLineNumbers")
' objKompilieren.Execute
End If
'Excel Verhalten setzen
With Application: .EnableEvents = True: .ScreenUpdating = True: End With
Exit Sub
Fehlerbehandlung:
'Excel Verhalten setzen
With Application: .EnableEvents = True: .ScreenUpdating = True: End With
'Fehler verursachen (wird im Anschluss in der Hauptprozedur gespeichert)
Err.Raise Err.Number, " | subProjektAutomatischKompilieren", Err.Description
End Sub
The two relevant lines of code are highlighted in bold.
This procedure works for adding line numbers to itself, but not throughout the whole project.
Any ideas or other ways to add line numbers?
Kind regards
I'm using the MZ-Tools 8.0 Add-In, which allows for inserting line numbers throughout my Code. This works great, but has to be triggered manually each time I modify the code.
So, I attempted to automate this together with each time the project is compiled:
'Automatisches Kompilieren des Projekts (wird vor dem Speichern ausgeführt) (Nebenprozedur)
Sub subProjektAutomatischKompilieren()
On Error GoTo Fehlerbehandlung
'Excel Verhalten setzen
With Application: .ScreenUpdating = False: .EnableEvents = False: End With
'Lokale Variablen dimensionieren/speichern
Dim objVBEMenüBar As Object
Dim objKompilieren As Object
Set objVBEMenüBar = Application.VBE.CommandBars
'Projekt kompilieren falls Code verändert wurde
Set objKompilieren = objVBEMenüBar.FindControl(Type:=msoControlButton, ID:=578)
If objKompilieren.State = msoButtonUp Then
objKompilieren.Execute
' Set objKompilieren = objVBEMenüBar.FindControl(Type:=msoControlButton, Tag:="AddLineNumbers")
' objKompilieren.Execute
End If
'Excel Verhalten setzen
With Application: .EnableEvents = True: .ScreenUpdating = True: End With
Exit Sub
Fehlerbehandlung:
'Excel Verhalten setzen
With Application: .EnableEvents = True: .ScreenUpdating = True: End With
'Fehler verursachen (wird im Anschluss in der Hauptprozedur gespeichert)
Err.Raise Err.Number, " | subProjektAutomatischKompilieren", Err.Description
End Sub
The two relevant lines of code are highlighted in bold.
This procedure works for adding line numbers to itself, but not throughout the whole project.
Any ideas or other ways to add line numbers?
Kind regards