Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi all, I have a problem.
I try to replace a procedure (named Dynamic_Macro) at run-time, by delete the procedure and then add it again using VBE. That's work succesfully... But when I try to execute that new procedure, the Excel always close and restart again. I have add timer between create the procedure and execute process, but still cause Excel restart. I'm sure nothing wrong with the new procedure, 'cause when I separate the executing coding, it's executed succesfully. My coding is : Dim VBCodeMod As CodeModule Dim StartLine As Long Dim HowManyLines As Long Dim LineNum As Long strScript = "" Set VBCodeMod = ThisWorkbook.VBProject.VBComponents("Module2").Cod eModule With VBCodeMod 'Delete proc Dynamic_Macro StartLine = .ProcStartLine("Dynamic_Macro", vbext_pk_Proc) HowManyLines = .ProcCountLines("Dynamic_Macro", vbext_pk_Proc) .DeleteLines StartLine, HowManyLines 'Add again proc Dynamic_Macro strScript = "" ReadText "Macro.txt", strScript LineNum = .CountOfLines + 1 .InsertLines LineNum, strScript Application.Wait (Now() + TimeValue("0:00:50")) Application.Run "Dynamic_Macro" End With ReadText is a procedure that read Dynamic_Macro content from a file text "Macro.txt" and pasing to strScript variable. Please would should I do in order to I can excute it immediately after created in one procedure? Thanks for your help, Resant |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Resant,
I haven't tested this, but maybe if you force a re-compile in the code it might work Application.VBE.CommandBars.FindControl(ID:=578).E xecute -- HTH Bob Phillips (replace somewhere in email address with gmail if mailing direct) "Resant" wrote in message ps.com... Hi all, I have a problem. I try to replace a procedure (named Dynamic_Macro) at run-time, by delete the procedure and then add it again using VBE. That's work succesfully... But when I try to execute that new procedure, the Excel always close and restart again. I have add timer between create the procedure and execute process, but still cause Excel restart. I'm sure nothing wrong with the new procedure, 'cause when I separate the executing coding, it's executed succesfully. My coding is : Dim VBCodeMod As CodeModule Dim StartLine As Long Dim HowManyLines As Long Dim LineNum As Long strScript = "" Set VBCodeMod = ThisWorkbook.VBProject.VBComponents("Module2").Cod eModule With VBCodeMod 'Delete proc Dynamic_Macro StartLine = .ProcStartLine("Dynamic_Macro", vbext_pk_Proc) HowManyLines = .ProcCountLines("Dynamic_Macro", vbext_pk_Proc) .DeleteLines StartLine, HowManyLines 'Add again proc Dynamic_Macro strScript = "" ReadText "Macro.txt", strScript LineNum = .CountOfLines + 1 .InsertLines LineNum, strScript Application.Wait (Now() + TimeValue("0:00:50")) Application.Run "Dynamic_Macro" End With ReadText is a procedure that read Dynamic_Macro content from a file text "Macro.txt" and pasing to strScript variable. Please would should I do in order to I can excute it immediately after created in one procedure? Thanks for your help, Resant |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks for your reply, Bob
But it's still doesn't work. The Excel still restart. Any other idea please? Bob Phillips wrote: Resant, I haven't tested this, but maybe if you force a re-compile in the code it might work Application.VBE.CommandBars.FindControl(ID:=578).E xecute -- HTH Bob Phillips (replace somewhere in email address with gmail if mailing direct) "Resant" wrote in message ps.com... Hi all, I have a problem. I try to replace a procedure (named Dynamic_Macro) at run-time, by delete the procedure and then add it again using VBE. That's work succesfully... But when I try to execute that new procedure, the Excel always close and restart again. I have add timer between create the procedure and execute process, but still cause Excel restart. I'm sure nothing wrong with the new procedure, 'cause when I separate the executing coding, it's executed succesfully. My coding is : Dim VBCodeMod As CodeModule Dim StartLine As Long Dim HowManyLines As Long Dim LineNum As Long strScript = "" Set VBCodeMod = ThisWorkbook.VBProject.VBComponents("Module2").Cod eModule With VBCodeMod 'Delete proc Dynamic_Macro StartLine = .ProcStartLine("Dynamic_Macro", vbext_pk_Proc) HowManyLines = .ProcCountLines("Dynamic_Macro", vbext_pk_Proc) .DeleteLines StartLine, HowManyLines 'Add again proc Dynamic_Macro strScript = "" ReadText "Macro.txt", strScript LineNum = .CountOfLines + 1 .InsertLines LineNum, strScript Application.Wait (Now() + TimeValue("0:00:50")) Application.Run "Dynamic_Macro" End With ReadText is a procedure that read Dynamic_Macro content from a file text "Macro.txt" and pasing to strScript variable. Please would should I do in order to I can excute it immediately after created in one procedure? Thanks for your help, Resant |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
how can I execute stored procedure to download data | Excel Programming | |||
execute stored procedure from excel | Excel Worksheet Functions | |||
execute stored procedure | Excel Programming | |||
Execute procedure on startup | Excel Programming | |||
Execute stored procedure using DAO | Excel Programming |