Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 73
Default Problem transferring VBA code w/ ProcOfLine & ProcBodyLine to VB.NET

I like to convert an Excel VBA Addin to VB.net to have it as a COM
addin (Visual Basic 2010 Express)
The Problem: Normally when using ProOfLIne the parameter ProcKind
returns the "vbext_ProcKind"
but in vb.net it returns every time 0 (vbext_pk_Proc)
The same Code in VBA does function correctly.
Because of this ProcBodyLine throws an error whenever the Line of a
Property should be determined.
Anyone an idea how to solve this?
my VB.Net code (almost identical to VBA)

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) ' <<<
delivers always 0 for ProcKind!
If Not ProcName = oldName Then
oldName = ProcName
myButton1 =
moduleCmdBar.Controls.Add(msoControlButton)
Select Case
TypeOfProc(.Lines(.ProcBodyLine(ProcName, ProcKind), 1)) '<<< throws
error when asking for line of a property
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
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem transferring Excel macros to another language svenstar Excel Programming 1 September 15th 09 11:15 AM
Transferring Data from Code to a Textbox in the Form TomP Excel Programming 4 January 12th 09 05:35 PM
Problem with transferring data JeffJ Excel Programming 1 June 8th 07 11:50 PM
Transferring from sap to excel problem nugre Excel Programming 0 March 26th 07 12:33 PM
transferring code from VBA to a VB dll PM Excel Programming 4 November 5th 04 02:20 PM


All times are GMT +1. The time now is 11:16 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"