Wednesday, 12 August 2015

Code Today: Create a kml file with VBA

Hi, another nerdy post today. The other day I came across some code I had written that generates a .kml file that points to a street address. It is a little kludgy but it has worked for the last few years. First I will show the code, explain it, then I'll talk about what I'd do differently if I were to do it now.

Sub Create_kml()
       
    Dim Name, Details, Address As String
    'Get job details into RAM
    Name = Range("Q3") & Range("R3")
    Details = Range("M3")
    Address = Range("K4")
   
    'Open kml file
    Dim fso, tf
    Set fso = CreateObject("Scripting.FileSystemObject")
    Set tf = fso.CreateTextFile("File Location" & Name & ".kml", True)
    'Write actual kml file
    tf.Writeline ("<?xml version=""1.0"" encoding=""UTF-8""?>")
    tf.Writeline ("<kml xmlns=""http://www.opengis.net/kml/2.2"" xmlns:gx=""http://www.google.com/kml/ext/2.2"" xmlns:kml=""http://www.opengis.net/kml/2.2"" xmlns:atom=""http://www.w3.org/2005/Atom"">")
    tf.Writeline ("<Document>")
    tf.Writeline ("    <Placemark>")
    tf.Writeline ("        <name>" & Name & "</name>")
    tf.Writeline ("        <description>" & Details & "</description>")
    tf.Writeline ("        <address>" & Address & "</address>")
    tf.Writeline ("        <styleUrl>#m_ylw-pushpin</styleUrl>")
    tf.Writeline ("    </Placemark>")
    tf.Writeline ("</Document>")
    tf.Writeline ("</kml>")
    'Clear buffer and finalise file
    tf.Close
End Sub

So I may have to look into better ways of displaying code in Blogger. But I think you get the gist of this. The Name variable is used for the name of the waypoint in the kml. The Details variable is used for the description of the waypoint and the address is the street address for the pin to get put on. Looking at it you can probably omit the fso object as it is only used once so you would just have a longer command to set the text file object.

The tf object is created with a specified file. Then writing it is just a case of pushing lines to it. The only way I know of to use a template for writing a file like this is by coding it in place like this.

The biggest thing I would do differently knowing what I know now is that rather than hard coding the locations to get the variables (Name, Details & Address) from. I would pass them to the sub(or write it as a function) so I can copy the code and re-use it without any modification.

Any questions or comments are appreciated.

I hope this helps someone with a project somewhere along the line.

Cheers,
Rex

Wednesday, 5 August 2015

Disable Animation in Microsoft Excel 2013

A bit of a nerdy post today.

So I recently got a new computer at work. Along with the new hardware and the performance that comes with it I got a copy of Microsoft office 2013. This is taking some getting used to. However there are a few little niggles that have been bothering me.

One of these that I have been able to fix is the animation within Excel. I'm not quite sure why this has been set up but it is easy enough to fix. Continue past the break to see how to fix this "feature"

Wednesday, 29 July 2015

The big reveal...

So last week I put up a photo of a largish brown box in my ute.
A Pretty unassuming box.
So contained within this box was a brand new welder. This is what I bought. A MIG 220BZ 3-in-1 welder from Rossi. This will do MIG, TIG and Stick welding and hopefully allow me to finish some projects I've had in the back of my mind for a while. After the break you can follow along with me as I open the box and give my initial thoughts (Uneducated in the nuances of welding as they may be)

Friday, 24 July 2015

What's in the box?

Hmm. What could be in this box? 
Next week I'll have the unboxing and I'll show what this very exciting box contains.

Wednesday, 15 July 2015

Snow is cold

So with the recent cold weather it has been snowing at my mate's place up the highway a little. So seeing as snow is a bit of a novelty for us we decided to the the jeep for a drive and play around in it a little. Here are some photos from that:

Lets see what I can stay on while being towed. It's a shame we didn't get a picture of me on the snowboard. That actually slid.

It was a little chilly, probably should have put on another jumper.

Now the jeep has a hood ornament. They actually nearly lasted the whole way home.

There's a lot of heat coming up from that bonnet. I might see if I can put some vents in to help it keep cool.

Nice and warm at home before we left. Sort of.

Cold and wet, not much fun.

Cold and snowy, more fun than cold and wet.

Not many people were overtaking on the highway.







We had a good afternoon and proved that the Jeep can handle a little snow at least. If it stays this cold there may be some pictures coming up of it in muddy snow.

Cheers,
Rex

Wednesday, 8 July 2015

Hammer Time

So I wanted to use my new diy forge to make something recently. The only problem there is I didn't have a hammer to use as my housemate has been using his elsewhere for a while. My brother had a few old hammer heads that he has found around the place so I figured that with some of the old wood that has been in the shed for a while we could make a new handle for a hammer.
This is what we started with.
For a brief look at what is possible to do for free follow on after the break.

Wednesday, 1 July 2015

Shaving Dangerously

So for the last few weeks I've been using a new razor I bought from here: http://www.safetyrazor.com.au/
This is the razor I've been using. It's very similar to a straight razor, however it uses replaceable blades. This means that I don't have to worry about honing or stropping to have a nice sharp edge.

The stuff I ordered.
So after using this razor for a few weeks I have been very happy with it. I have nicked myself and had to use the styptic pencil. Thankfully that was only one morning. I'm hoping to buy a proper brush and a bar of shaving soap soon which I expect will improve my shaves significantly.

Just quickly, on the styptic pencils. I had to look a little to find instructions on their use. So here is my method from what I found. After cutting yourself you wet the end of the pencil so it will leave a little of itself behind when rubbed on the skin. Then just rub the tip of it on the cut. This will sting a little depending on how bad you've nicked yourself. Once you've rubbed it around for a short time just rinse the blood off the pencil and put it somewhere to dry.

So apparently the way they work; is when the pencil is wetted it leaves a little of itself behind in the cut when you rub it in. The main thing that does the job is called Alum which I believe is an aluminium oxide of some description. It works by causing the tissue in that are to shrink. In particularly the capillaries that have been broken. This shrinking is what stems the flow of blood.

Once I get a brush and soap I will write a followup and discuss any differences I find with that as well.

Cheers,
Rex