A really good example of scripting the InternetExplorer.Application with downloads

Here is someone who wanted to automate downloads with consistency as seems to have achieved it. It has some SendKeys in it so it is not autonomous – but is a great example of getting it done no matter what. Well done. I am looking for code to see if a machine is alive in < 5 seconds. If not, alert the user to wait. It has an Http Basic Authentication popup that I am trying to get through using tools natively installed on Windows. Of course Curl can do it but that requires all users installing it which is not acceptable for this use.  I need 4 concepts from this article. Here is the msdn on InternetExplorer.Application.

http://www.vbaexpress.com/forum/showthread.php?42206-IE-Automation-File-Open-IE8-IE9 

My code if it was a userform username / password would be like this. Basically you can’t easily unless the registry value is changed specifically allowing the username/password to be sent along in the url. Here is an idea that no one validating has having worked and is in powershell. People did get it working using SendKeys – which I do NOT want. Curl it is! This stuff is not good to post online, but alas, explains why one should NOT store their passwords on any browser.

Adding jQuery to ANY page via local browser – greasemonkey

Here are lots of links on how to find out what to use

http://stackoverflow.com/questions/2283134/how-can-you-implement-a-jquery-feature-without-having-ie-prompt-users-with-an-ac

Settled in on greasemonkey for Firefox.

http://stackoverflow.com/questions/11569293/what-browser-plugin-that-lets-you-override-html-of-a-website-automatically
http://en.wikipedia.org/wiki/Greasemonkey
http://stackoverflow.com/questions/859024/how-can-i-use-jquery-in-greasemonkey

Debugging – can’t get this working with the latest versions of things.  Another Link and I have given up with Firebug or Web Developer Tools.

suggest loading local js file (does not work – so again – forget local debugging!!) 

Blocked Content warning in Firefox – simply press the shield in the upper left corner of the url.

Storing vars across pages

VBA inheritance and interfaces – can it be done?

First, my head hurts at then end of this so this post will be short until I can back to it and digest this stuff. Can VBA implement an interface like c#, cocoa or java? I have been using this stuff without really “getting it”. Now that we have a very smart individual who started with my client as a programmer (I am an engineer) he is bending my head a lot and really helping me see things from his perspective. Thanks man! So – now that I am using VBA … I could use some of this esteric ideas … or can I. This article is well written but I have to go home now.

http://stackoverflow.com/questions/19881863/how-to-use-comparison-methods-between-class-object-modules-in-vba-in-a-similar-m/19908375#19908375

Singleton classes in VBA

 

Excel to XML to avoid direct OPENROWSOURCE SQL data connection to Excel

The company I am currently solving issues for will not accept Excel as a table data source. This I know, so therefore a really really great report cannot go on the live system. So I have been beating my head on how to get around the politics – good politics because Excel is a breakable table (which is why they won’t/don’t like it). But … how do we move forward AND satisfy IT? Well, an interim solution would be to use XML as the SQL Server data source and then build a url driven Service to extract data from Excel into this XML data source. So … links to get started you ask?

Can life get easier? What will the world be like in 10 years. This took me 5 minutes to see if we could do it. Now it is an interim solution because Excel is still the data source, but all we have to do now is replace Excel with an official app on the web in the near future – but to do this properly requires many many weeks of development, whereas a service – either works or doesn’t and only requires unit tests, not people to test is my simplistic view on this.

VBA to … export VBA modules for archiving or other

Neat. http://www.cpearson.com/Excel/VBE.aspx  Now I can export the modules for text version control  (so we can see the changes). AND use it to standardize all the code between little small projects to ensure that all the good ideas from one period in time can be compared to other projects done in an earlier time.

For instance, lets say we made a great “look for header” routine 4 months ago. Today, the header row is not fixed to row 1 any longer. If we make a new routine that is a little more generic – it needs to have a different name but if we backdate all the other routines, then the idea is better for all projects. The tools in the above link give us all we need to get this completed. … and the code above works – with few changes.

Finding most likely Excel A1 cell to place text blocks in

So, I had some manually entered non-tables in an AutoCAD document that I needed to get to an Excel format. Non tables literally refers to tables made by placing text in a rectangular x,y fashion. So these were Bentley ISO’s that the machine makes a material take off in the upper right corner. Not knowing that the future held in terms of the number of columns – this turned out to be a “get all x values and make a histogram of buckets x millimeters wide”. This is basically how communications determines wireless signals in quadrature (x/y plane). Since humans can enter text boxes alongside the machine – what is the best guess for the grid?

We could use some col math like the Verterbi algorithm – but that is a little too complicated. Basically making a histogram and determininig the best row and column was the best approach. Unlike wireless communication theory – the bucket widths are completely known w.r.t. to each drawing that we process AND the number of columns are unknown. What is known is that within a drawing – there are a consistent number of rows and columns.

It worked by the way.

Some links.

  • http://stackoverflow.com/questions/8979752/how-to-count-number-of-peaks-in-graph-graph-analysis
  • Verterbi algorithm: http://en.wikipedia.org/wiki/Viterbi_algorithm

Autocad- get to the field edit value of a block attribute

Well, this was like looking for a needle in a haystack. I tried to use google to know if a block attribute referred to text or to a formula that made the text. The key is looking at the extension dictionary. If there is one, it has dictionaries inside of them and if one of the items in named “ACAD_FIELD” then… yes this attribute is de-referenced or aliased or abstracted by using a formula. I was usinging the attributes .Text property which gives you the RESULT of the field formula underneath. I was doing search and replaces and blowing away the formulas – which would have been best left alone. Now I can skip them.

The guy here about 8 posts down AFTER reading the code was my hero on this one. It was after about 20 google searches.

Continue reading

Getting the user to pick an Excel cell range via a dialog …

I have made a couple tools with setup variables that I wish to keep in Excel and not really accessible to the end user per-se. So I use named ranges. However, rather than type up elaborate setup documents for a spreadsheet – the end user said “can I get a helper routine to fill all these in?”. Yes was the answer ONLY IF we could have the user pick selection ranges. So – using userforms and the Application.InputBox … I think we can! Here’s how… Continue reading