Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 114
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 114
Default 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
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
Check for Complie Error in VBA code via VBIDE ExcelMonkey Excel Programming 1 September 27th 09 01:20 PM
CodeModule.AddFromFile problem Frederick Chow Excel Programming 0 March 23rd 06 06:04 PM
Putting a formula in place one time for the entire spreadsheet jacob Excel Programming 2 August 3rd 05 01:26 AM
Putting a formula in place one time for the entire spreadsheet jacob Excel Programming 6 May 6th 05 03:39 PM
modifying code using addfromfile method PaulR Excel Programming 2 March 18th 05 11:10 PM


All times are GMT +1. The time now is 08:32 AM.

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

About Us

"It's about Microsoft Excel"