P
Peres
I copy this code from Peter’s page but Excell always get crash when try to
create de module.
I learned that it happens because It tries to compile the module when in
running mode.
So is it? One cant put this cod to work?
Oh: It is one Workbook creating code in another Workbook
Tks for any help
Sub CreateEventProcedure(Mnew) ‘Mnew is the new workbook
Dim VBProj As VBIDE.VBProject
Dim VBComp As VBIDE.VBComponent
Dim CodeMod As VBIDE.CodeModule
Dim LineNum As Long
Set VBProj = Mnew.VBProject
Set VBComp = VBProj.VBComponents("EstaPasta_de_trabalho")
Set CodeMod = VBComp.CodeModule
With CodeMod
LineNum = .CreateEventProc("Open", "Workbook")
LineNum = LineNum + 1
.InsertLines LineNum, "Application.Calculation =
xlCalculationAutomatic "
LineNum = LineNum + 1
.InsertLines LineNum, "ActiveWorkbook.UpdateLink
Name:=ActiveWorkbook.LinkSources"
LineNum = LineNum + 1
.InsertLines LineNum, "Application.Visible = False"
LineNum = LineNum + 1
.InsertLines LineNum, "Inputs1.show"
LineNum = LineNum + 1
.InsertLines LineNum, "Application.Visible = true"
End With
Worksheets(1).Activate
create de module.
I learned that it happens because It tries to compile the module when in
running mode.
So is it? One cant put this cod to work?
Oh: It is one Workbook creating code in another Workbook
Tks for any help
Sub CreateEventProcedure(Mnew) ‘Mnew is the new workbook
Dim VBProj As VBIDE.VBProject
Dim VBComp As VBIDE.VBComponent
Dim CodeMod As VBIDE.CodeModule
Dim LineNum As Long
Set VBProj = Mnew.VBProject
Set VBComp = VBProj.VBComponents("EstaPasta_de_trabalho")
Set CodeMod = VBComp.CodeModule
With CodeMod
LineNum = .CreateEventProc("Open", "Workbook")
LineNum = LineNum + 1
.InsertLines LineNum, "Application.Calculation =
xlCalculationAutomatic "
LineNum = LineNum + 1
.InsertLines LineNum, "ActiveWorkbook.UpdateLink
Name:=ActiveWorkbook.LinkSources"
LineNum = LineNum + 1
.InsertLines LineNum, "Application.Visible = False"
LineNum = LineNum + 1
.InsertLines LineNum, "Inputs1.show"
LineNum = LineNum + 1
.InsertLines LineNum, "Application.Visible = true"
End With
Worksheets(1).Activate