Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Installing JuliaExcel Erroring #14

Closed
chris-hampel-CA opened this issue Feb 3, 2023 · 8 comments
Closed

Installing JuliaExcel Erroring #14

chris-hampel-CA opened this issue Feb 3, 2023 · 8 comments

Comments

@chris-hampel-CA
Copy link

Hello,

I was following the installation steps with Excel closed. After executing JuliaExcel.installme(). I see a message that says the Installer script has been launched, please respond to the dialogs there. However, I see what appears to be an error message show up.

image

When I open excel and type =Julia in Excel it is not recognizing the command so I assume the installation did not occur correctly.
Am I missing a step? Any other ideas why the installation would have errored?

Thanks, Chris

@PGS62
Copy link
Owner

PGS62 commented Feb 4, 2023

I don't think you're "missing a step". What appears to be happening is that the install script is failing quite early, at the point when it's trying to detect whether or not Excel is already running. The offending code is a method called CheckExcel that calls a method IsProcessRunning that I think I cribbed from this StackOverFlow post.

Here's a very hacky solution that might work:

  1. Ensure that Excel is really not running - preferably using TaskManager to check that no "ghost" Excel process is running.
  2. Open C:\Users\Christopher Hampel.julia\packages\JuliaExcel\Y1cgX\Installer\install.vbs
    (which is a copy of this file) in a text editor.
  3. Comment out line 458 (a call to CheckExcel) by typing a single quote character at the start of the line.
  4. Save the file.
  5. Run the amended file by double-clicking it in file explorer.

Good luck!

@chris-hampel-CA
Copy link
Author

Thanks for the suggestion @PGS62 . I attempted this after a restart of my computer, with no instance of Excel showing in the Task Manager, and found a new error occurring

image

Can you verify that line 458 is the correct line to make the comment on? I used the single quote to comment next to the beginning of the text in line 458.

image

@PGS62
Copy link
Owner

PGS62 commented Feb 14, 2023

Ah sorry, I must have been looking at an out of date copy of install.vbs. You should comment out line 449.

image

@chris-hampel-CA
Copy link
Author

chris-hampel-CA commented Feb 14, 2023

Ok thanks. Your suggestion for commenting out line 449 allowed me to complete the installation successfully! I don't know if this is a global issue or just local to me. I will let you decide how you want to handle it going forward. The issue can certainly be closed.

Also, while I have you here, I have two more quick questions about this tool (as I'm really excited to use this in hopes to allow non-coders to interface with julia tools that I work on)

  1. I want to make julia functions that are specific to a project available to be called with JuliaCall. I originally added the JuliaExcel package to a project env and did the installation; however, when opening Excel, I could only call =JuliaLaunch() successfully if I added the JuliaExcel package to my base env. How can I launch a JuliaExcel session in Excel such that it calls julia in a project env?
  2. Also in testing this, I noticed that if I run some simple =JuliaEval() expressions when working in my base env, the correct outputs appear in Excel as expected, but when I close and re-open the same file, the outputs go away. They re-appear if we launch julia again and press enter again in all the cells with JuliaEval calls. My question: is there a way to make the julia outputs stay visible when re-opening Excel such that a JuliaEval expression can be evaluated only once? My use case is: I want to call a function that runs a model and displays the resulting data such that when I close Excel and re-open, my previous model run's data is still available for viewing. The data could then only be overwritten by re-launching Julia and evaluating the expressions again. (I realize you can turn calculations to MANUAL in Excel after finishing your julia function evals, close and re-open and the data will still be there as I want. This seems like a work around, but I am curious if there is a more advanced feature that I may not be aware of.)

Thanks, Chris

@PGS62
Copy link
Owner

PGS62 commented Feb 15, 2023

The failure of the installer script on your PC was a surprise to me - I'd not seen that before. Is your PC "locked down" in some way, perhaps by a corporate IT department (anti-virus etc.)?

In answer to your questions:

  1. JuliaLaunch has a CommandLineOptions argument. I think that you should be able to pass "--project c:/path/to/environment" as that argument and things should work as you want them to. (Note unix-style forward slashes in the path!) See command-line switches for Julia. I have not tested this today (and it's a while since I worked on JuliaExcel) so please let me know how you get on with this suggestion.

  2. To investigate I did the following
    a) opened a new workbook
    b) switched Excel calculation to Automatic
    c) entered formula =JuliaLaunch() in cell A1
    d) entered formula =JuliaEval("1:100") in A2 - to populate cells A2 to A101
    e) Saved, closed and reopened the workbook
    f) Observed that A2 to A101 were still populated.

I then put a breakpoint in the VBA code of JuliaEval and discovered that when re-opening the workbook JuliaEval is called. I think this means that Excel is treating cell A2 as containing a "volatile" formula. So I think MANUAL calculation is your best bet.

@chris-hampel-CA
Copy link
Author

chris-hampel-CA commented Feb 17, 2023

My PC is controlled by corporate IT. It is difficult for me to know if it is locked down by anti-virus but I could imagine it being likely.

  1. Your tip did work. Although I found the documentation tricky to follow because of [ in --project[={<dir>|@.}] listed in the documentation is not actually supposed to be used. I did as so julia --project="C:/Users/Christopher Hampel/Documents/AnalysisCA" . For anyone reading who also has an IT department who puts a pesky space in their home dir which proved to be an annoyance when doing this, you have to type the JuliaLaunch command like so. =JuliaLaunch(FALSE, TRUE, CONCAT("--project=",B1)) where B1 is a cell specified as a text type "C:/Users/Christopher Hampel/Documents/AnalysisCA" (and the first two args are optional)

  2. The MANUAL mode will work but it just takes diligence to know to turn excel to manual mode before opening a workbook that is known to contain JuliaExcel functions.

I have one final question. Do you know if plots can appear as figures in Excel from a JuliaEval command?

Thanks for all your prompt and thorough responses, Phillip!

@PGS62
Copy link
Owner

PGS62 commented Feb 21, 2023

No, JuliaEval certainly can't "return a plot" in the sense that a VBA function (which juliaeval is) cannot return an Excel chart when called from an Excel worksheet.

I think you have two options:

  1. Have your Julia function return data to the worksheet and use Excel's charting functionality to plot it.
  2. Have your Julia function generate a plot, save that plot to file (say in .svg) format and write code in the Worksheet_Calculate event of the worksheet's class module that inserts a picture into the sheet, based on that .svg file. I would only attempt this option if the plot\chart you want to generate is of a kind that's beyond Excel's capability. It's also a question of how much experience of VBA you have.

@PGS62 PGS62 closed this as completed Feb 21, 2023
@chris-hampel-CA
Copy link
Author

That makes sense. Thanks for all the help, again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants