Jasenc Posted March 30, 2012 Posted March 30, 2012 Hey Guys Can someone help me please Im busy putting together a dcl file with a 'info' button when you click on the info button i want it to open a excel spreadsheet is this possible? at the momnet i can get it to open a web page but i can seem to get to open the excel file Below is a example of my code : list_box { label = "Size"; list = "M6\nM8\nM10\nM12\nM16\nM20\nM24\nM30"; value = ""; key = "nut_bolt_size"; } : row { ok_button; cancel_button; : info_button { action = "(startapp \"explorer\" \"http://www.mypage.com\")"; }} Quote
irneb Posted April 1, 2012 Posted April 1, 2012 Explorer is usually in one of your windows paths - so you can start it by simply adding its name to the startapp function. This just sends the command to windows, it searches for such command or exe file in its paths and if found starts it with the parameters supplied. Excel is installed in a different folder (usually something like "C:\\Program Files\\Microsoft Office\\Office ##\\Excel.exe" or something in that order). Now you should probably find out where it's installed on your PC, but it might vary between PC's, versions of Excel, and 32/64bit. So the task is a bit complicated, and probably needs some registry probing to find out where Excel is installed. An simpler alternative would be to directly call the file through Explorer. This would then try to use the registry root classes to open the program configured to open that class of file. If Excel is installed properly this should work. It's basically as if you've double clicked on the file in an Explorer Browser window. (startapp "Explorer" "C:\\Path to File\\Filename.XLS") Or another more convoluted way would be to start Excel through ActiveX and then open the file from that - but then I'd not place the code inside the DCL - you need to release such objects otherwise ACad might crash. The benefit from this would be that you can control Excel, read / write inside the XLS file using all of Excel's COM library interface. Basically performing the first steps of this: http://www.theswamp.org/index.php?topic=38450.0 BTW, what your sample shows is already using the simpler interface. You "think" you're opening the web page in Explorer, but all it's actually doing is noticing it's an http web page and then passing that along to IExplorer (Internet Explorer). The Explorer.EXE is mainly the drive/file browser itself (and your desktop), it doesn't open web pages in itself, just passes it along. If you've setup a different default internet browser (e.g. FireFox/Opera/Chome/Safari/SeaMonkey) that same call would actually open the page in such browser instead of IExplore. Quote
Jasenc Posted April 2, 2012 Author Posted April 2, 2012 Thank you for helping on this , but for some reason it work with in the dcl file if create a button and assign a macro to it it works fine I basically want to hit the info button and it opens a excel dpread sheet any more ideas ? Quote
irneb Posted April 2, 2012 Posted April 2, 2012 any more ideas ?Do you mean this doesn't work for you? An simpler alternative would be to directly call the file through Explorer. This would then try to use the registry root classes to open the program configured to open that class of file. If Excel is installed properly this should work. It's basically as if you've double clicked on the file in an Explorer Browser window.(startapp "Explorer" "C:\\Path to File\\Filename.XLS") Quote
Jasenc Posted April 2, 2012 Author Posted April 2, 2012 Ok basically this is what i have in my code : row { ok_button; cancel_button; : info_button { action = (startapp "Explorer" "C:\\Path to File\\Filename.XLS") but this doesnt seem to work , I get a saying bad object synatx symbol :"action", I take it Im doing something wrong teh my code after the info_button section Quote
irneb Posted April 2, 2012 Posted April 2, 2012 Yes, if you want to place such call into the DCL file itself, then you need to convert the (startapp ... ) call into a string. Notice how your first post looked. I.e. it needs to look something like this: "(startapp \"Explorer\" \"C:\\\\Path to File\\\\Filename.XLS\")" Note the path & filename you need to supply - just remember to escape the double quotes and backslashes as done here. A quick way would be to use acad to do such for you. Type the following at acad's command line: (progn (prin1 (getstring t)) (princ)) Paste the path into the command line & press entet - it will return a quoted string for you which you can select & copy to clipboard. Quote
Jasenc Posted April 2, 2012 Author Posted April 2, 2012 Hi there thanks so much , finally got it to work thank you again for replying to my posts Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.