Jonathan-LeRoux / IguanaTex

A PowerPoint add-in allowing you to insert LaTeX equations into PowerPoint presentations on Windows and Mac
http://www.jonathanleroux.org/software/iguanatex/
Other
802 stars 57 forks source link

Run-time error "91": Objective variable or With block variable not set #12

Closed Raymond30 closed 3 years ago

Raymond30 commented 3 years ago

First of all, thank you for developing such an amazing tool! It is really one of the few reasons why I choose to stick with PowerPoint:)

I have used IguanaTex for a while without any issue until I tried the external editor feature. Here are the steps to reproduce the run-time error:

  1. Click "New LaTeX display", use external editor to write any latex code, and generate.
  2. Select the figure and click "Edit LaTeX Display". This will lead us to the external editor.
  3. After editing the code and save it, click "Reload the modified code" or "Cancel". Now a run-time error will pop up (see below). On the other hand, "Generate the modified code" works perfectly. image

In case it is relevant, I am using PowerPoint 2019 on Windows 10, and VS code is my external editor.

Jonathan-LeRoux commented 3 years ago

I just tried with my setup (PowerPoint 2016 on Windows 10, TeXstudio as external editor) but couldn't reproduce the error. Could you try using another external editor first to make sure that's not related to some VS code idiosyncrasy (I doubt it, but better to check), then maybe try using the debug mode by trying this from the .pptm version of the add-in? Basically, open the .pptm as a normal presentation, then try the same thing. This should allow you to get to the line of code that's causing the issue. Thanks, Jonathan

Raymond30 commented 3 years ago

I changed my external editor to Windows Notepad but the error persists. I tried the debug mode as you instructed, and it turns out PPT crashes at this line: image And if I am not mistaken, this is the location in the source code: https://github.com/Jonathan-LeRoux/IguanaTex/blob/a12959ba7db7fa4c53a42a650f7a1952c22712b5/LatexForm.frm#L1866

I am not familiar with Visual Basic though, so could you please tell me what else I need to do to pin down the problem? Thanks for your help!

Jonathan-LeRoux commented 3 years ago

Thanks for looking at this. This is a line that is supposed to control the mouse wheel in the editor window. I added this in v1.53. Interestingly, the mouse wheel doesn't work for me anymore, so this may be a version issue. Can you try commenting that whole function out? Just add single-quotes at the beginning of each line. Unless I find a fix to make the mouse wheel work again, I may remove this function.

Raymond30 commented 3 years ago

Yes, it works! Commenting out the whole function does the trick. Thanks again for your help!

Jonathan-LeRoux commented 3 years ago

Great! Now I need to figure out if there's a way to implement mouse wheel support so that it actually works and doesn't break anything else 🙂

Jonathan-LeRoux commented 3 years ago

I now see why you were having this issue and I couldn't reproduce it: I assume you had "Use external editor as default" turned on, and I hadn't. In that case, the IguanaTex editor window is in a different state (a "Modeless" state, in contrast with the usual "Modal" state where the user needs to explicitly close the editor window), and the code that is supposed to make it scrollable with the mouse wheel crashes. By the way, I also noticed in the process that even with "Use external editor as default", the first time each display is created, the user still needs to click on the button to launch the external editor. I'm wondering what's the best behavior here. If a user has some default settings they rarely modify, then opening directly to the external editor would make sense. But one can also imagine that users may want to tweak some settings (font size, bitmap/vector), which are only available in the IguanaTex window. Still, in that case, they could always do so by "reloading" the code at the end in the edit window, so I guess launching directly makes sense. I'm open to comments.

So, I had to fix 3 things:

I'll push the updated code in the next few days. Thanks for making me realize these issues!

Raymond30 commented 3 years ago

You're right—I did turn on the "Use external editor as default" option (unknowingly) and had not idea this would make a big difference. I am glad that the problem is now clear:)

Personally, I am actually fine with the current design where we need an extra click to open the external editor for new displays but not for existing displays. This gives me the option to use the built-in editor for some simple formulas, and meanwhile avoid unnecessary clicks when repeatedly modifying a complicated expression. As for tweaking other settings, I find that "Regenerate selection" is a better alternative than reloading (it even allows batch processing!). So my workflow is like this:

  1. Depending on the task, I write LaTeX in the IguanaTeX window right away or decide to launch the external editor.
  2. When I hope to change the appearance (font size etc.), I use "Regenerate selection".
  3. When I hope to modify the content, I click "Edit LateX display" and the external editor will pop up.

These are just my personal views and I hope it helps.

P.S. As a non-programmer, it strikes me a bit how seemly "routine" functions can be tricky to implement. I really appreciate your hard work and devotion to this wonderful project.

Jonathan-LeRoux commented 3 years ago

Thanks for the feedback. I think you're right that it could be annoying to always rely on the external editor for new displays. I removed that from the code. I like how you use "Regenerate Selection" to change appearance, that makes a lot of sense as an alternative if you default to editing in the external editor. Now I mainly need to package everything and upload to the website, hopefully today. Thanks again for your help.

Jonathan-LeRoux commented 3 years ago

v1.58 is now out, I'll close this issue. Thanks!