0

I am using VBA-macros in order to automate serveral data processing steps in excel, such as data reduction and visualization. But since excel has no appropriate fit for my purposes I use a python script using scipy's least squares cubic b-spline function. The in and output is done via .txt files. Since I adjusted the script from a manual script I got from a friend.

VBA calls Python

Call common.callLSQCBSpline(targetrng, ThisWorkbook) #calls python which works
Call common.callLoadFitTxt(targetrng, ThisWorkbook) # loads pythons output

Now the funny business: This works in debug mode but does not when running "full speed". The solution to the problem is simply wait for the directory were the .txt is written to refresh and to load the current and not the previous output file. My solution currently looks like this:

Call common.callLSQCBSpline(targetrng, ThisWorkbook)
Application.Wait (Now + 0.00005)
Call common.callLoadFitTxt(targetrng, ThisWorkbook)

This is slow and anoying but works. Is there a way to speed this up? The python script works fine and writes the output.txt file properly. VBA just needs a second or two before it can load it. The txts are very small under 1 kB.

Thanks in advance!

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
  • How about you run some itterations with different wait times to optimize the wait time? Also does it add a .txt file into the directory or does it overwrite an already present file? – Luuklag Aug 21 '18 at 10:19
  • my current idea is to use arrays as in and output as in another question: [https://stackoverflow.com/questions/51947269/how-does-one-capturing-shell-output-with-shell-run-instead-of-shell-exec-in-vba] – Lucas Raphael Pianegonda Aug 21 '18 at 11:14

0 Answers0