if theShell.ErrorCode <> 0 then
Run that, and select the file that you created in step 1.
If you select a file that doesn’t include an accented character, the shell command will open the file. If the path includes an accented character, the shell returns error code 1, “The system cannot find the path specified.”
I must be doing something pathetically obviously wrong here. How do I make this work with accented characters?
Thanks, Paul. That looks helpful if I were working with batch files and know which code page to specify, but I don’t know how I would go about applying that to a shell command that needs to work with an arbitrary file path.
This is probably really obvious to people who know more about Windows than I do, especially those who are more likely to have an accented character in their username. The actual example that I’ve seen from a customer is ““C:\Users\Cline\AppData\Local\Temp\257612791824.html””
It looks like Xojo is using the ASCII call instead of the Unicode call, try this (works here)
Declare Function ShellExecute Lib "Shell32" Alias "ShellExecuteW" (hwnd As Ptr, lpOperation As WString, lpFile As WString, lpParameters As WString, lpDirectory As WString, nShowCmd As Int32) As Integer
Dim ok As Integer
ok = ShellExecute(Nil, "open", theFile.NativePath, "", "", 5)
Thanks, Julian. Yes, it does rather look like Xojo might be using ASCII rather than Unicode.
Your example works well in my test case, so thanks for that. However, the real use case is rather more complicated in that I’m using a shell command to tell WKHTMLTOPDF to convert an HTML file to a PDF, like so:
Thanks, Julian. I’ve just tried what you suggested with a non-accented file path and, although the returned value is >32 and therefore according to this page not an error, something’s wrong with the call to WKHTMLTOPDF but I’m not sure where to find the error output.