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
902 stars 62 forks source link

BUG: Could not start process when open a file in OneDrive directory #34

Closed BreakVoid closed 2 years ago

BreakVoid commented 2 years ago

When I am editing a file in OneDrive directory, "Insert vector graphics file" does not work well. image

After I copied the file out of OneDrive directory, it works well.

aoconnor-ufl commented 2 years ago

Try making that OneDrive folder available offline and see if that helps.

Jonathan-LeRoux commented 2 years ago

Thanks for reporting this, I can reproduce this issue on my end.

This is due to the fact that the function to insert vector graphics uses the presentation folder as default location to launch a process, whereas other functions to create/edit displays use the Temp folder, and the Windows API function CreateProcessA does not seem to like being called with a OneDrive directory as the current directory. I'm not sure if that is a bug on the Windows API side or not, but anyhow, the directory in which we launch the process doesn't matter, as I (ironically) write in the comments: "The StartFolder doesn't really matter here because everything is relative to the input file, we just need any folder from which to launch the commands". Well, it turns out it does matter here!

The easy fix is to comment out the If ActivePresentation.path <> vbNullString clause:

    'If ActivePresentation.path <> vbNullString Then
    '    StartFolder = ActivePresentation.path
    'Else
    If GetTempPath() <> vbNullString Then
        StartFolder = GetTempPath()
    Else
        #If Mac Then
            StartFolder = "/"
        #Else
            StartFolder = "C:\"
        #End If
    End If

Here is an updated version of the .pptm with the fix: IguanaTex_v1_60_2.zip Please let me know if this work on your end.

BreakVoid commented 2 years ago

Thanks for reporting this, I can reproduce this issue on my end.

This is due to the fact that the function to insert vector graphics uses the presentation folder as default location to launch a process, whereas other functions to create/edit displays use the Temp folder, and the Windows API function CreateProcessA does not seem to like being called with a OneDrive directory as the current directory. I'm not sure if that is a bug on the Windows API side or not, but anyhow, the directory in which we launch the process doesn't matter, as I (ironically) write in the comments: "The StartFolder doesn't really matter here because everything is relative to the input file, we just need any folder from which to launch the commands". Well, it turns out it does matter here!

The easy fix is to comment out the If ActivePresentation.path <> vbNullString clause:

    'If ActivePresentation.path <> vbNullString Then
    '    StartFolder = ActivePresentation.path
    'Else
    If GetTempPath() <> vbNullString Then
        StartFolder = GetTempPath()
    Else
        #If Mac Then
            StartFolder = "/"
        #Else
            StartFolder = "C:\"
        #End If
    End If

Here is an updated version of the .pptm with the fix: IguanaTex_v1_60_2.zip Please let me know if this work on your end.

I downloaded the file and tried the pptm file by copying the file to OneDrive directory. The function works well. Thanks a lot.

Jonathan-LeRoux commented 2 years ago

Thanks for confirming! v1.60.2 release closes this issue.