I have a Solidworks PDM transition that launches a particular Excel sheet that has a Workbook_Open routine that receives a parameter passed in from PDM. That parameter is the %folderpath% of the file being transitioned in PDM. The Excel routines run fine. However, Excel is trying to do too much with the passed in path. After the routine in Excel runs, an Excel dialog is throw as shown here:
Excel is mashing the passed in path with an .xlsx extension (its running a .xlsm file). Here is the command line being executed in PDM "C:\Program Files (x86)\Microsoft Office\Root\Office16\EXCEL.EXE""C:\Users\guy\Desktop\TEST FOLDER RENAME.xlsm" /e/ %FolderPath% where the full folder path is C:\PTI\ECO\General\CR-0023482. Any ideas on why Excel is throwing this message and is there a way to suppress/stop it?
I found the issue and it is subtle. The command line in PDM's transitions action cannot have a space between the called spreadsheet and the passed in parameter. This argument works. "C:\Temp\F-Rename.xlsm"/e/%FolderPath% vs. "C:\Temp\F-Rename.xlsm" /e/%FolderPath%.
Related
I have this issue where an Excel file appears to be opened when I use Python although there is no Excel instance running. It is impossible to see it via Windows, even with the hidden files option selected ; only using Python in this case (the last item in the list on the last line of code) :
Moreover, it persits even when I tried the following :
Deleting the file,
Copy/paste the whole folder somewhere else,
Renaming the file,
Rebooting...
This is a nightmare... I can't figure why windows would keep a hidden file openened somewhere.
#Boris
Is there someone who has opened/editing this file on a remote/remote desktop connection?
I use an XLAM file to store a few subs for general spreadsheet purposes. The XLAM is added and checked in the VBA editor's references and has worked for 4+ months without any issues. Most of the functions are pretty basic, like creating PDF's or refreshing connections in whatever spreadsheet calls the subs that reside in the XLAM file.
A few days ago, none of my morning processes ran, and when I checked what happened I had 10 "recovered" files which, when I went to check repairs, Excel said there was nothing wrong with them. I tried to step through the subs to see where they failed, but each one crashed without an error message from VBA, they just failed completely. I tried running the macros through a vbs file called from Powershell and I received the message "The remote procedure call failed" on the line which called the macro.
I did not change any code in any of my workbooks or in the XLAM file, nor did I change the references to the XLAM in any way. In addition, the code consistently works on my co-worker's machines.
I've been calling the functions from the XLAM file as follows:
Call Project.Module.Function/Sub(argument)
Maybe it is an issue with the RPC but I really do not know, any help would be greatly appreciated, and I'm happy to post more code.
Is there a way to make Excel ignore certain command line arguments? I am launching via a command similar to:
Excel "C:\Temp\TestingCLAs.xlsx" /e service=http://localhost:61023/api/PortlandDev/2/ReportSource?Order='100146309'^&Line='0010'
The service string gets read by some VBA in the Excel file and is used to update a query. However, when I launch Excel the command line argument interpreter see's two things:
Open "C:\Temp\TestingCLASs.xlsx"
Open service=http://....
I would like the interpreter to ignore the second argument, however I get the following error when opening:
"Sorry, we couldn't find
service=http://localhost:61023/api/PortlandDev/2/ReportSource?Order='100146309'&Line='0010'.xlsx.
Is it possible it was moved, renamed or deleted?
I know this isn't due to the VBA within the excel file because it happens even when testing with a blank excel file.
I found this reference article: https://blogs.msdn.microsoft.com/twistylittlepassagesallalike/2011/04/23/everyone-quotes-command-line-arguments-the-wrong-way/ and tried to escape the URL with a '^' character but, got the same result.
Also looking at the error above, a .xlsx is tacked on to the end of the second URL above when it wasn't specified in the initial call.
Is there a way to make the command interpreter not try to execute the URL?
Any ideas are very much appreciated. Thanks
Not sure why it works but passing a "/p" switch makes it so that the command interpreter does not try to automatically open the URL. For example, the following can be consumed by my internal VBA without the command interpreter trying to create a new workbook from the URL.
Excel "C:\Temp\Template.xlsm" /e /p http://localhost:61023/api/PortlandDev/2/ReportSource?Order='100142574'&Line='0010'
I'm looking for a way to have Excel files in my Matlab folder open 'outside Matlab' (i.e., by MS Excel in most cases) directly by double-clicking the file, rather than right-clicking and selecting 'Open Outside Matlab'.
The .xls files reader built in Matlab can be terribly slow for large files, and an unwanted double-click on a file can cost quite some time in which Matlab is unresponsive.
Thanks.
When you click something in the Current Folder tab, it's actually running the open command, which itself calls finfo to determine what it means by "open" for a given extension. You can see this by creating a breakpoint in open.m directly after the line [~, openAction] = finfo(fullpath); and double clicking - when it hits the breakpoint you'll see it returns openAction as uiimport.
In theory, you can create custom methods for extensions by creating on the path a function openabc where abc is the extension, which should be returned as the openAction.
However, if I look at my finfo.m it first searches for said functions and then regardless of whether or not it finds them if there is an inbuilt method it overwrites them with the standard behaviour. There's even a comment:
% this setup will not allow users to override the default EXTread behavior
If you are willing to muck about in the inbuilts, you may be able to do it like this (backup first! - this could affect other things). I did it temporarily by shadowing the existing finfo like this:
edit finfo.m (Now save a copy to the current folder)
Add these lines after the loop that defines the openAction (in my version, around line 85):
if any(strcmp(['.' ext], matlab.io.internal.xlsreadSupportedExtensions))
openAction = 'winopen';
end
From the folder containing your edited finfo.m, type which finfo -all. You should see two copies, the MATLAB one labelled as shadowed. Opening something from the current folder window should now open Excel externally.
I don't believe there's any straightforward way to do that. It's built in to MATLAB that Excel files will open in the import tool when you double click on them, and there's no way to change that.
You might be able to get around it by changing the file extension on your Excel files to something other than .xls or .xlsx. That would stop MATLAB from opening it in the import tool. Then in Windows, you could associate the new file extension with Excel.
is there a way how to make Matlab open excel files directly in MS Excel? I do not mean just read data, but physically open MS Excel.
I have a script that processes some data and saves it into .xlsm. This .xlsm contains auto_open macro which generates a report and saves it into another .xls.
I want the process to be as automatic as possible. So far, when the matlab script ends, .xlsm file needs to be open manually. Is it possible to do it via Matlab? (The .m file and .xlsm are in the same folder.)
The simplest way to open (but not close) an Excel file is to use WINOPEN:
winopen('myFile.xlsx')
Excel has a powerful COM interface that lets you control it from another application.
Look here for the matlab side of things
http://www.mathworks.co.uk/help/techdoc/ref/actxserver.html
And here for an example of putting it all together . . .
https://www.quantnet.com/forum/threads/interface-between-matlab-vba-excel.2090/
or here is another example
http://www.mathworks.co.uk/support/solutions/en/data/1-716EAM/index.html?solution=1-716EAM
Yes, it is possible. Matlab can use Excel's Automation interface to do this and similar tasks. The following code loads Excel and then loads a workbook:
try
w = actxserver('Excel.Application'); % Fails if Excel not installed
catch
w = [];
end
if ~isempty(w)
w.Workbooks.Open('D:\Documents\MATLAB\file.xlsx');
% Your code here;
w.Quit;
end
delete(w);
You will need to look at Microsoft's documentation for the Excel automation interface to figure out exactly what commands you need to send. Try starting here.
I have used this technique to drive Word from Matlab in order to produce a report document, but I have never used Excel this way, so unfortunately I can't help you with the gory details!