[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.vb.general.discussion

Procbodyline error in VB.net, but not in VBA Editor

minimaster

2/16/2011 9:27:00 AM

I have a routine in Excel VBA which uses ProcBodyLine to retrieve a
procedure name and it works fine without any problems. I like to
convert my addin into a VB.Net based COM addin and now ProcBodyline
throws an error whenever it has to retrieve the name of a property.
Anyone an idea how I can manage to avoid these errors to retrieve the
name of these properties correctly.

my VB.Net code:

Imports Microsoft.Office.Core
Imports Excel = Microsoft.Office.Interop.Excel
Imports VBIDE = Microsoft.Vbe.Interop
Imports Microsoft.Vbe.Interop.vbext_ProcKind
Imports Microsoft.Vbe.Interop.vbext_ComponentType

Private Sub addRoutinesToPopup(ByRef moduleCmdBar As CommandBar, _
ByRef VBComp As VBIDE.VBComponent)

Dim ProcKind As VBIDE.vbext_ProcKind
Dim LineNum As Long
Dim ProcName As String
Dim oldName As String = ""
With VBComp.CodeModule
LineNum = .CountOfDeclarationLines + 1
Do Until LineNum >= .CountOfLines
ProcName = .ProcOfLine(LineNum, ProcKind)
If Not ProcName = oldName Then
oldName = ProcName
myButton1 =
moduleCmdBar.Controls.Add(msoControlButton)
Select Case
TypeOfProc(.Lines(.ProcBodyLine(ProcName, ProcKind), 1))
Case "Sub"
myButton1.FaceId = 186
Case "Sub with Param."
myButton1.FaceId = 187
Case "Function"
myButton1.FaceId = 385
Case Else
myButton1.FaceId = 190
End Select
With myButton1
.Caption = ProcName ' the sub or
Function name
.Parameter = TheMacroFile 'ADDIN_NAME '
the file name containing the macros
.Tag = VBComp.Name ' the
code module name
.OnAction = "!<MacroLister.Connect>"
End With
End If
LineNum = LineNum + .ProcCountLines(ProcName,
ProcKind)
LineNum = LineNum + 1
Loop
End With
End Sub
2 Answers

DaveO

2/16/2011 9:40:00 AM

0

"minimaster" <hartmut.gruenhagen@bakerhughes.com> wrote in message
news:a1cfad05-a5d4-4c8a-967a-c51f510b8ef5@k30g2000yqb.googlegroups.com...
> I like to
> convert my addin into a VB.Net based

That's nice - However this newsgroup is for VB6 and older only. If you want
help with the .NET stuff I would have suggested one of these:
microsoft.public.dotnet.languages.vb
microsoft.public.dotnet.languages.vb.upgrade
microsoft.public.dotnet.languages.vb.controls
microsoft.public.dotnet.languages.vb.data
microsoft.public.dotnet.general
microsoft.public.vsnet.general

But Microsoft in an attempt to make everything as hard and unpleasent to use
as possible have closed down most (if not all) of their Usenet groups,
hopefully the groups still exist on some mirror servers or on the web based
newsgroup which to me seem to be more about generating advertising revenue
than diseminating information.

Dave O.


minimaster

2/16/2011 10:05:00 AM

0

Sorry for posting in the wrong forum, I've re-posted it in
microsoft.public.dotnet.languages.vb.
Thx for the hint.