Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
VBIDE.Codemodule.addfromfile putting code in wrong place
Dear all,
I am using VBIDE.Codemodule.addfromfile "NameOfFile.bas" to append a procedure to a VBComponent. The problem is that in this VBComponent I have variables declarations and one in the middle that is Public, and the VBE engine is appending the procedure several lines above this declaration, although the first procedure is several lines bellow. Any suggestion? Thanks, GM |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
VBIDE.Codemodule.addfromfile putting code in wrong place
Show your code.
On Oct 16, 6:07*pm, Guga wrote: Dear all, I am using VBIDE.Codemodule.addfromfile "NameOfFile.bas" to append a procedure to a VBComponent. The problem is that in this VBComponent I have variables declarations and one in the middle that is Public, and the VBE engine is appending the procedure several lines above this declaration, although the first procedure is several lines bellow. Any suggestion? Thanks, GM |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
VBIDE.Codemodule.addfromfile putting code in wrong place
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 |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
VBIDE.Codemodule.addfromfile putting code in wrong place
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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Check for Complie Error in VBA code via VBIDE | Excel Programming | |||
CodeModule.AddFromFile problem | Excel Programming | |||
Putting a formula in place one time for the entire spreadsheet | Excel Programming | |||
Putting a formula in place one time for the entire spreadsheet | Excel Programming | |||
modifying code using addfromfile method | Excel Programming |