BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Adding a Workbook_BeforePrint event

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi OLE Automation
View previous topic :: View next topic  
Author Message
Nico Callewaert
Guest





PostPosted: Wed Nov 26, 2003 2:57 pm    Post subject: Adding a Workbook_BeforePrint event Reply with quote




Hi,

I've made a VBA event in Excel : Workbook_BeforePrint.
How can I automatically insert that in a sheet through
Delphi-automation ?

Many thanks, Nico Callewaert
Back to top
Nico Callewaert
Guest





PostPosted: Wed Nov 26, 2003 9:04 pm    Post subject: Re: Adding a Workbook_BeforePrint event Reply with quote




Hi again,

I found already the solution to my macro problem, but
now I have another question : is it possible to delete
a inserted macro after the job is finished ?

Thanks in advance, Nico Callewaert


"Nico Callewaert" <nico_callewaert (AT) hotmail (DOT) com> wrote:
Quote:

Hi,

I've made a VBA event in Excel : Workbook_BeforePrint.
How can I automatically insert that in a sheet through
Delphi-automation ?

Many thanks, Nico Callewaert


Back to top
David
Guest





PostPosted: Thu Nov 27, 2003 7:32 am    Post subject: Re: Adding a Workbook_BeforePrint event Reply with quote




var
VBC : _VBComponent;
cm : CodeModule;
i : integer;
begin
VBC :=
ExcelApplication.VBE.ActiveVBProject.VBComponents.Add(vbext_ct_StdModule);
cm := VBC.CodeModule;

// goto the end of the CodeModule
i := cm.CountOfLines;
cm.InsertLines(2 + i, 'Sub YourMacro');
...
cm.InsertLines(2 + i + 2, 'End Sub');

ExcelApplication.Run('YourMacro');

ExcelApplication.VBE.ActiveVBProject.VBComponents.Remove(VBC);
end;

this way you can run any macro and delete it.


Am 26 Nov 2003 14:04:19 -0700 hat Nico Callewaert
<nico_callewaert (AT) hotmail (DOT) com> geschrieben:

Quote:

Hi again,

I found already the solution to my macro problem, but
now I have another question : is it possible to delete
a inserted macro after the job is finished ?

Thanks in advance, Nico Callewaert


"Nico Callewaert" <nico_callewaert (AT) hotmail (DOT) com> wrote:

Hi,

I've made a VBA event in Excel : Workbook_BeforePrint.
How can I automatically insert that in a sheet through
Delphi-automation ?

Many thanks, Nico Callewaert



Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi OLE Automation All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.