SeniorNewbie
Board Regular
- Joined
- Jul 9, 2023
- Messages
- 77
- Office Version
- 2021
- 2019
- Platform
- Windows
- MacOS
Hi out there!
may be someone here can help me to "remove the potatoes from my eyes" (a German saying for temporarily blindness). I need a procedure which react on the contents in a module code. Therefor it has to be read first what I'm trying with this snippet (Extensibility 5.3 must be activated):
As you can see the line CountofLines - 4 is deactivated. Run the code in a testmodul and you'll see it works. But not this bloody line -4. Error message "Argument is't optional"
There's a similar code block in another module- and there it works. I compared it line by line, character by character, but I can't find the mistake.
Any ideas? THX in advance!
Senior Newbie
may be someone here can help me to "remove the potatoes from my eyes" (a German saying for temporarily blindness). I need a procedure which react on the contents in a module code. Therefor it has to be read first what I'm trying with this snippet (Extensibility 5.3 must be activated):
VBA Code:
Option Explicit
Sub vbCodeTest()
Dim i As Long, iLine As Integer, sModule As String
Dim vbProj As VBIDE.VBProject, vbComp As VBIDE.VBComponent, vbCode As VBIDE.CodeModule
sModule = "Modul1"
Set vbProj = ThisWorkbook.VBProject
Set vbComp = vbProj.VBComponents(sModule)
Set vbCode = vbComp.CodeModule
MsgBox vbCode.CountOfLines
For i = 1 To vbCode.CountOfLines
'Debug.Print vbCode.Lines(i)
Debug.Print i
Next
End Sub
There's a similar code block in another module- and there it works. I compared it line by line, character by character, but I can't find the mistake.
Any ideas? THX in advance!
Senior Newbie