LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default VBA Extensibility library and dynamic code compilation

I've never had luck with code changing code - Excel often becomes
unstable.


That's interesting, because I've written tons of code that manipulates code
in modules and Designer objects. The only problem that I've ever had is when
code attempts to modify the module that contains the code doing the
manipulation, i.e. a module modifying itself. That causes problems, but as
long as I stay away from that module, I've had no problems. Maybe quirks,
but not such that I would call them "problems" or that Excel became
"unstable".


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
(email address is on the web site)


"Bernie Deitrick" <deitbe @ consumer dot org wrote in message
...
John,

I've never had luck with code changing code - Excel often becomes
unstable. My solution is to set up a workbook template with all the event
code required, then copy it whenever I need it. Unless you are creating
custom code dynamically, it may work for you as well....

HTH,
Bernie
MS Excel MVP


"John.Greenan" wrote in message
...
I have inherited a VB6 application that runs unattended and creates an
Excel
2002 spreadsheet dynamically using the Excel library.

The VB6 code then uses the VBA Extensibility library to access the
created
worksheet and then adds a "worksheet_calculate" event using
mycodemodule.CreateEventProc("Calculate", "Worksheet")

This "worksheet_calculate" event code is then populated by the VB6 code
writing some VBA using

mycodemodule.InsertLines lngTargetLine, strHeaderLine1

This works ok and we see that the VBA code works properly, but when the
worksheet is opened by a user we find that we cannot change any of the
data
in the worksheet with calculation set to automatic - editing any cell
will
repeatably cause Excel to crash out.

To change the worksheet values we either
(a) switch calculation to manual, change the sheet and then put
calculation
back to automatic
OR
(b) we enter VBA and compile the worksheet using "Tools""Compile VBA
Project".

If we change the worksheet without making one of these changes then we
find
that Excel just crashes out. This appears to be an Excel bug.

So, if we could find a "proper" way to get the VBA in the
worksheet_calculate to be compiled we would not face this problem.

As you will know, the VBE library has no inbuilt method to compile VBA
(MakeCompiledFile and BuildFileName are only for VB6 code to create a
.dll
rather than compile VBA) and I am not happy about trying to implement a
nasty
send keys method.

Has anyone encountered this and worked out a way to do this that does not
use sendkeys???

Cheers,

John
--
www.alignment-systems.com





 
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
Extensibility Library Mike Molyneaux Excel Programming 5 March 2nd 06 07:06 PM
VB Extensibility Library - 97 to 2002 George J[_2_] Excel Programming 9 August 2nd 05 11:19 AM
VBA extensibility library for deleting forms, modules, code etc... Ajit Excel Programming 2 November 19th 04 03:41 AM
VBA extensibility Library aspadda[_2_] Excel Programming 3 November 19th 04 03:39 AM
VBA extensibility library for deleting forms, modules, code etc... Frank Kabel Excel Programming 0 November 18th 04 07:06 PM


All times are GMT +1. The time now is 10:02 PM.

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

About Us

"It's about Microsoft Excel"