|
title: Put the knife down and take a green herb, dude. |
descrip: One feller's views on the state of everyday computer science & its application (and now, OTHER STUFF) who isn't rich enough to shell out for www.myfreakinfirst-andlast-name.com Using 89% of the same design the blog had in 2001. |
|
FOR ENTERTAINMENT PURPOSES ONLY!!!
Back-up your data and, when you bike, always wear white. As an Amazon Associate, I earn from qualifying purchases. Affiliate links in green. |
|
|
x
MarkUpDown is the best Markdown editor for professionals on Windows 10. It includes two-pane live preview, in-app uploads to imgur for image hosting, and MultiMarkdown table support. Features you won't find anywhere else include...
You've wasted more than $15 of your time looking for a great Markdown editor. Stop looking. MarkUpDown is the app you're looking for. Learn more or head over to the 'Store now! |
|
| Monday, January 05, 2015 | |
|
What? You're trying to open an html file with Excel that you just made from scratch [with another app]? Why would you do that? Well, for one, this seems to be the preferred way to use PowerShell to make Excel files when you want to control colors and other UI-specific information along with data. It's kind of strange that, when one of PowerShell's most useful group of functions is centered around creating and manipulating CSV files, you wouldn't have similar modules for Excel, but fine (Scripting Guy says it's because of Excel's heavy use of COM [1]). So you get a nice html template, you have PowerShell data-i-fy it all up, you go to Excel to open it, and then BAM. "You are attempting to open a file type (Web Pages and Excel 2003 XML Spreadsheets) that has been blocked by your File Block settings in the Trust Center." Wait, what? The Trust Center? I mean, I understand when I have to Unblock-File on ps files I've sourced from the Net, but an html file I created (yes, "all by myself") in SeaMonkey [sic]? RLY, Excel? You can follow the instructions and wade into your Trust Center to say, "Forget it. I want Excel to open ANY html file, whether I created it or not, in spite of the fact that you could've just checked to see if I'd created it and only stopped me if things were much more suspicious." Or you can try to do that and find your company's IT dept has made it impossible to change your Trust Center settings even though you have admin access for nearly anything else. Well, if you find you're in the second group (the one with not exactly consistently enforced IT security policies) there's a workaround: Put your html file that you want Excel to open in a "trusted location". Who knew? Good thing the bad guys will never learn where the locations are and exploit this extra trust. Here's a list of Trusted Locations for Excel 2010 -- a list that will look like crud until I monospace it (sauce: [3]):
If you're not using 2010 or are looking for something similar for Word, etc, that info is here: http://support.microsoft.com/kb/922849 And voila. Look at that html file you painstakingly created and filled with data, now mangled beyond belief by that bastion of spreadsheet integrity, Excel! You're welcome. ;^) [1] http://blogs.technet.com/b/heyscriptingguy/archive/2014/01/10/powershell-and-excel-fast-safe-and-reliable.aspx [2] http://technet.microsoft.com/en-us/library/hh849924.aspx [3] http://technet.microsoft.com/en-us/library/cc179039(office.14).aspx Labels: excel, powershell posted by ruffin at 1/05/2015 01:11:00 PM |
|
| Thursday, August 09, 2012 | |
|
Okay, maybe vba-ing your way from Excel files to raw SQL isn't the way most folks extract, transform, and load, but I like it okay when you get an Excel file of values. This code is essentially the same as this jive from 2009, but I like that I've finally given up on adding a UserForm, naming it, adding a text box, naming it too, then stretching each until they look like a finished product. Instead, I now just add a form, double-click a TextBox on there, and let this programmatically do the rest. Option ExplicitLabels: code, excel, noteToSelf, vba posted by ruffin at 8/09/2012 01:13:00 PM |
|
| Wednesday, June 20, 2012 | |
![]() Word to the wise: SQL*Loader doesn't like Mac file endings. Use TextWrangler's Save As to convert to Windows (or UNIX) file endings to make your csv sqlldr ready. Labels: excel, noteToSelf, oracle, os x posted by ruffin at 6/20/2012 09:01:00 AM |
|
| Wednesday, April 20, 2011 | |
|
So if you want to automate Excel 2008 with Applescript, you have to minimize your tells. There are some strange scoping interferences. For instance, this code breaks. tell application "Microsoft Excel"Try to compile/run and you get "Syntax Error -- Can't get "E" in "ABCDEFG". Access not allowed." Wack. Fun times with text manipulation and Excel automation, eh? So code that borks like that needs to be pulled out of the tell block. You maintain values that were pulled out of Excel references, so it's not a big deal other than the inherent wackiness. So in my code now, the tell block to Excel is very small. -- it seems like you could do all this work within telltheValue sticks around afterwards and my stock/simple string manipulation calls work again, so no problems. Not sure if doing the tell inside of instead of outside of my logic's loops causes some big bridge between Excel and Applescript to be built, destroyed, and built again, but it's already so freakin' slow it's not like it really matters. There's fast as in "give it to me now" and 'fast' as in "give it to me in a few hours after I go for a run, to the grocery store, and do the dishes". This is in the second, and is nearly already in the "go to sleep on it and hope it's done in the morning" category that comes afterwards. I hate this. (I ran into this "sleep on it" speed at a shop that used Crystal Reports against very large databases and it drove me MAD. It was bad enough I took the time to figure out a way to have Crystal use SQL directly against the DB, moving the logic where it's supposed to go -- the database -- and left Crystal just with formatting. Thank heavens. Even if I personally only used it a few times, give me a break, folk. We went from clients waiting all night -- even DAYS at times -- for reports to them waiting a few minutes at worst. It's not 1980 any more! Your workstations are fast if you're not gaming, okay? (Not 1980, that is, unless you're using Applescript to automate Excel 2008, apparently.)) FUN IN KLUDGEVILLE!!! I'll probably repost my "practical example" as it is now in a bit. It's not clean at all. Drives me a little crazy. Labels: applescript, code, excel, problem solved posted by ruffin at 4/20/2011 02:00:00 PM |
|
| Tuesday, April 19, 2011 | |
|
This stinks. Really. Say what you will about Microsoft, they know how to create and maintain a programming language. Whoever thought that s/vbscript/Applescript/gi would be a fair substitution in Office for Mac (even ignoring that it breaks legacy macros) was not a programmer. Here's what my "final" code looks like. It's a mess and needs cleaning. But something that's INSANELY EASY in vbscript takes the below to do something similar. I couldn't even get it to know what cell format selections I'd made in Excel and ended up with an ugly kludge for zip codes and a hellah ugly kludge for phone numbers which were coming out in a format like "9.195553662E+9". What a mess. I could clean it up some, taking out lesser kludges that aren't working, but I think you get the point better as is. Not intuitive. Not fully-featured. The stuff you have to roll yourself in Applescript (afaict) is insane and inane. Boy. Talk about not feeling fully featured. Now I have to let it wade through over 3000 lines of Excel tonight... 1 on replaceText(find, replace, subject)(Edit: See this on tells. I had to tweak the above a good bit for it to work well, but it still serves as a pretty decent low-investment Applescript (vs. VBA) code snippet. It's an order of magnitude more complicated.) Labels: applescript, code, excel, problem solved, vba posted by ruffin at 4/19/2011 04:07:00 PM |
|
|
I have Excel 2008 on my Mac. About the only complicated thing I ever want to do with Excel files is to manipulate them line by line and spit the output into a cut and pasteable source for my clipboard. I have a vbscript version for Windows, but when I'm in 2008 land, I'm sunk. No vbs. Only Applescript. Stinks. Frustrated with having to wait until I'm back on my Windows box, not yet willing to shell out more cash and buy Office 2011 (and fed up enough with Office 2004 that I threw it away the second 2008 hit my box), I'm finally going to figure out how to port the code to Applescript. So first let's essentially run Hello, World, and put a value into a specific Excel cell. tell application "Microsoft Excel" Going to Sheet2 is exactly like you'd expect. tell application "Microsoft Excel" So once we start playing around, we'll probably want some way to keep track of what we've found. In my case, I want to turn line after line from an Excel file to SQL statements. Instead of a giant dialog box, I'll just slap that into a file. set theText to "some text" So now all we've got to do is to throw the contents of each cell into theText. So now we need to find out how to iterate through all Excel cells? This took a little longer that I would have expected. The key is this line: get value of cell c of row r of active sheet That takes the place of .Cells(x,y) So here's the end result. tell application "Microsoft Excel" This is PAINFULLY slow, however. I'm used to it screaming. I tried rearranging the code to write out the jive to the file with each line, and that's not noticeably quicker. tell application "Microsoft Excel" So it works, in a sort of brute force, inefficient way. The biggest issue I've had is if it's cancelled. Though it says "error in the loops", the file ref seems not to be closed, and then the file I'm writing to remains open with no opportunity to close it. Once the script's done, it just remains open. I tried deleting on the command line with Terminal and the file was still "there" as far as the script was concerned. Perhaps when I reboot it'll be gone, but I can't Google a way to close it. Most answers seem to talk about finding the app that opened it, but when you're the app that did it, I'm not sure what's up. In any event, it does marginally spider through cell by cell and print things out to a text file, which is what I wanted. You just have to be really patient. No wonder they added Labels: applescript, code, excel, noteToSelf, problem solved posted by ruffin at 4/19/2011 02:16:00 PM |
|
| Tuesday, April 27, 2010 | |
|
For some reason, I routinely seem to forget how to do this in the months between my using formulas in Excel 2004. viewing cell contents in toolbar: I may be confused here, but the only thing I know of that can be put in a toolbar is a control. The Formula Bar (choose View/Formula Bar) has the formula box control, where the contents of the active cell are displayed. Ctrl-U is a nifty alternative, but I prefer to have the Formula Bar visible. Labels: excel, noteToSelf, problem solved posted by ruffin at 4/27/2010 12:09:00 PM |
|
| Sunday, August 30, 2009 | |
|
Update 20100216: Now it even works! ' from http://support.microsoft.com/kb/188007Labels: excel, noteToSelf, vba posted by ruffin at 8/30/2009 06:27:00 PM |
|
| Sunday, August 16, 2009 | |
|
(trilingal, I am, yeeeeeees.) Option Explicit Yes, yes, I already knew all this, but if you only use Cells(rows, columns) once every three or four years, it's good to have a refresher. Labels: code, excel, noteToSelf, vba posted by ruffin at 8/16/2009 12:29:00 PM |
|
|
| |
|
|
All posts can be accessed here: Just the last year o' posts: |
|||||||||||||||||||||
|
||||||||||||||||||||||
|
|
|
|