Quantitative Analysis
Parallel Processing
Numerical Analysis
C++ Multithreading
Python for Excel
Python Utilities

I. Motivation and design (PFE).
II. Installation of the Python for Excel.
III. Tutorial introduction into the Python for Excel.
1. Stability guarantee.
2. PythonForExcel ControlShell.
3. What to do if the connection to Excel from the ControlShell is lost or if the prompt "waits" for too long.
4. Possible littering of memory with orphaned Excel processes.
5. In-cell execution of Python statements.
6. Calling Python from VBA.
7. Calling VBA from Python.
8. Debugging with Python for Excel.
9. Unicode support.
10. Deactivation of Python for Excel.
11. Very important note about pfe-script execution.
IV. PFE Programmer's reference.
Index. Contents.

Very important note about pfe-script execution.

reate a fresh workbook and place the following code into the ThisWorkbook module.

01\ Option Explicit

02\ Private Sub Workbook_Open()

03\ Dim ws As Worksheet

04\ Set ws = ThisWorkbook.Worksheets(1)

05\ Call ws.Cells.Clear

06\ ws.Range("b1").Activate

07\ ws.Range("a1").Value = "Everything is OK."

08\ End Sub


Create a Module and place the following macro code.

01\ Public Sub testMacro(i As Integer)

02\ ThisWorkbook.Worksheets(1).Range("a1").Value = i

03\ End Sub


Save, close and reopen the workbook. Go to VBA window and execute the following line in the "Immediate" window.


The Excel application becomes non-responsive. This happens with a freshly created workbook, when all add-ins are deactivated, including the PFE addin. Only the VBA code is involved. The result is the same for Excel 2000 and Excel 2010.

There are three points that I want to propose after such experiment.

First, no matter how hard I try I cannot shield dear user from the fact that Excel remains to be a buggy application. Not every bug is my fault.

Second, the ExecuteExcel4Macro works fine in most situations. Perhaps, using the Activate() methods in the "open workbook" event handler is not a good idea. The pfe-files are a principal tool of this product and these are executed in the "open workbook" event handler. Please, remember that there are slightly different rules of execution for the pfe-script itself and for the event handlers that the pfe-script installs.

Third, Excel bugs are easy to replicate and localize. Consequently, there is always a reliable way around any bug that you might encounter.

Index. Contents.

Copyright 2007