Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Re Inserting Code for addin

2 views
Skip to first unread message

k_zeon

unread,
May 3, 2009, 6:22:55 PM5/3/09
to
I would like to create an addin but am having some difficulties

in a newly created VB6 exe in the IDE you get

Option Explicit

Private Sub Form_Load()

End Sub


if i run my addin i get the correct results.
ie
Option Explicit

Private Sub Form_Load()
My Inserted Text <<<<< This is my inserted code
End Sub

if however i add some lines of code and white space as follows
ie

Option Explicit
Dim test as string
<<Space
<<Space
<<Space
Private Sub Form_Load()

End Sub

Now if I run my Addin I get


Option Explicit
Dim test as string
<<Space
My Inserted Text <<< This should be inside the Form_Load
<<Space
Private Sub Form_Load()

End Sub

He is the code i use to find the Form_Load Procedure

Private Function FindStartPlace(ByVal Stext As String) As Long
On Error Resume Next
Dim strProcNameExisits As Boolean
Dim lngProcStartLine As Long
Dim lngProcLineCount As Long
'
strProcNameExisits =
VBInstance.CodePanes.VBE.ActiveCodePane.CodeModule.Find(Stext, 1, 1,
VBInstance.ActiveCodePane.CodeModule.CountOfLines, 0, False, False)

If strProcNameExisits = False Then Exit Function

lngProcStartLine =
VBInstance.CodePanes.VBE.ActiveCodePane.CodeModule.ProcStartLine(Stext,
vbext_pk_Proc)

FindStartPlace = lngProcStartLine + 2
End Function


This will see the number of lines of code but does not take into account the
Blank Lines with Nothing there

I hope someone can help

Many thanks

Garry

Kevin Provance

unread,
May 3, 2009, 9:53:36 PM5/3/09
to
You need to use the Find method, locate Sun Form_Load, which I believe
returns it's line number and use that return value to insert your text on
the correct line value. Messed up, I know...but that's what I did.

--
2025
If you do not believe in time travel,
your beliefs are about to be tempered.

http://www.facebook.com/group.php?gid=43606237254
"k_zeon" <silverm...@googlemail.com> wrote in message
news:OR2W82D...@TK2MSFTNGP03.phx.gbl...

Nobody

unread,
May 3, 2009, 10:20:02 PM5/3/09
to
"k_zeon" <silverm...@googlemail.com> wrote in message
news:OR2W82D...@TK2MSFTNGP03.phx.gbl...


You need to use ProcBodyLine instead of ProcStartLine. ProcStartLine gives
you the first line of a procedure that would include any header. This is the
same line that appear after the separator in the IDE. ProcBodyLine gives you
the actual Sub/Function/Property declaration line.

k_zeon

unread,
May 4, 2009, 2:28:37 AM5/4/09
to
thanks. I used ProcBodyLine and this solved my problem

many thanks

"Nobody" <nob...@nobody.com> wrote in message
news:OOUPb7Fz...@TK2MSFTNGP02.phx.gbl...

0 new messages