This a simple example of how you might use regular expression searching in conjunction with the Application_PostNCCreate event. Also see Example of Using the Regular Expression (RegExp) Object.
Option Explicit
Public Sub Application_PostNCCreate(Doc As FeatureCAM.MFGDocument, _
ByVal nc_file_name As String, _
ByVal macro_file_cnt As Long, _
ByVal macro_file_names As Variant)
Dim buffer As String
MsgBox "Searching NC File for line numbers. File is " & nc_file_name
MsgBox "Visit the Immediate window to see the results."
Open nc_file_name For Input As #3
While Not EOF(3)
Line Input #3,buffer
Debug.Print buffer
' Search for N number at beginning of line
Debug.Print RegExpTest( "^N[0-9]+", buffer )
Wend
Close #3
End Sub
Function RegExpTest(patrn, strng) As String
Dim regEx As RegExp
Dim Match As Match
Dim matches As MatchCollection
Dim RetStr As String
Set regEx = New RegExp ' Create a regular expression.
regEx.Pattern = patrn ' Set pattern.
regEx.IgnoreCase = True ' Set case insensitivity.
regEx.Global = True ' Set global applicability.
Set matches = regEx.Execute(strng) ' Execute search.
For Each Match In matches ' Iterate Matches collection.
RetStr = RetStr & "Match found at position "
RetStr = RetStr & Match.FirstIndex & ". Match Value is '"
RetStr = RetStr & Match.Value & "', "
RetStr = RetStr & "Match length is "
RetStr = RetStr & Match.Length & "." & vbNewLine
Next
RegExpTest = RetStr
End Function