Was your .bas file exported from Excel? The sample on the MS site
uses a plain Text file, so maybe that's the problem.
http://support.microsoft.com/kb/245801
Tim
On Oct 17, 5:15*am, Guga wrote:
Sub AddProcedureToModule(CodeMod As VBIDE.CodeModule, ProcName As
String)
ProcName = ActiveWorkbook.Path & "\" & ProcName & ".bas"
CodeMod.AddFromFile ProcName
End Sub
Example of output code:
Const iEmpresasGrupo As Integer = 14
Const sIGs As String = "XPTO"
Const sForadoGrupo As String = "FORA DO GRUPO"
Dim bSilentMode As Boolean
Const cChave As Integer = 1, _
* * * * cNivel As Integer = 2, _
* * * * cTipo As Integer = 3, _
* * * * cRubricaShow As Integer = 5, _
* * * * cRubricaEdit As Integer = 6, _
* * * * cIG As Integer = 7, _
* * * * cDir As Integer = 8, _
* * * * cFirstValue = 10, _
* * * * cLastValue = 56, _
SUB PROCNAME
* * * NEW CODE
END SUB
* * * * cFilter = 95, _
* * * * cFiltroIntroducao = 87, _
* * * * cChaveComposta = 104
'Other variables:
Public rCelulaActiva As Range
Dim rCelula As Range
Dim iAnswer As Integer
Dim iContador As Integer
As you can see the new procedure is being inserted in the middle of
the declarations... The .CountOfDeclarationLines property returns the
correct number of lines, which would result in the insertion of the
new procedure to be in the right place.
I am working in a work around with .insertlines method.
Thanks for your reply.
Regards,
GM