The Collings Zone

The home of Adam & Linda Collings

Welcome to Adam and Linda's place. We are a Christian couple from Tasmania. We have two adorable children. Here you will find some of our writings, and a little other material. Make yourself at home.

Home   |   About Us   |   Adam's Writing   |   Software Projects   |   The Blog

Search the Bible with BibleGateway.com
  
  
  
BibleGateway.com is a service of Gospelcom.net

Monday, August 31, 2009

Stack Overflow with Word Automation Replace - SOLVED

When performing Word automation, Word will sometimes throw a System.StackOverflowException, which you cannot catch, while performing a find/replace operation. It is usually the Find.Replacement.ClearFormatting(); call that leads to this exception.

The solution to this is simple, use late binding. In fact, it is recommended that you use late binding whenever performing office automation.



The resulting code would be something like

object Selection = oWord.Selection;
object myFind = oWord.Selection.Find;
object Optional = Type.Missing;
object wd = Word.WdReplace.wdReplaceAll;
object[] Parameters;
object findText = "Findtext";
object replaceText = "Replacetext";

Parameters = new object[15];
Parameters[0] = findText;
Parameters[1] = Optional;
Parameters[2] = Optional;
Parameters[3] = Optional;
Parameters[4] = Optional;
Parameters[5] = Optional;
Parameters[6] = Optional;
Parameters[7] = Optional;
Parameters[8] = Optional;
Parameters[9] = replaceText;
Parameters[10] = wd;
Parameters[11] = Optional;
Parameters[12] = Optional;
Parameters[13] = Optional;
Parameters[14] = Optional;

myFind.GetType().InvokeMember("Execute", BindingFlags.InvokeMethod, null, myFind, Parameters);

Don't forget to free the objects you have used

System.Runtime.InteropServices.Marshal.ReleaseComObject(oFind);
oFind = null;
System.Runtime.InteropServices.Marshal.ReleaseComObject(oSelection);
oSelection = null;

This succesfully resolved the problem for me.

Sources:

Labels:

Wednesday, August 19, 2009

Changing Boss - Romans 6

My musings on Romans 6

Romans 6 talks about being dead to sin and alive in Christ. This is a picture of what happens to a person when they become a Christian. By dying to sin we are set free from our slavery to it, and by being made alive in Christ we become a new creation. I think this relates to what Jesus means when he talks about 'the flesh' (our old life in sin), and 'the spirit' (our new life in Christ).

This chapter gives three steps to victory over sin in a Christian's life [1].

  1. Understand that you are dead to sin. (Verse 11) The sinful part of us is already dead or dying. When we allow this part of us to control our life we have a dead man behind the wheel. Our Spirit should be stronger because it is alive in Christ.
  2. Do not let sin reign in your life. (Verse 12)

  3. Offer yourself - your whole self - to God, in service, submission and love. (Verse 13)

I think parts 2 and 3 are closely linked. It is hard to not let sin reign in your life, unless it is replaced by something.

Verses 15 to 23 talk about being a 'slave to righteousness'. As a Christian, I have changed masters. I used to be a 'slave to sin', for which the wages are death. Now, I am a willing servent to righteousness, for which the reward is the free gift of eternal life.

I think of it this way, I have had three jobs since I graduated from University. As I left one job, and started another, I changed masters. I no longer obeyed my former boss. If I kept working for my previous boss, doing what he wanted me to do, while being paid by my current boss, I probably wouldn't have a job for very long. So why do we do it in life? Picturing it this way helps me to remember where my allegience lies and who I should be living for.



References
[1] NIV Bible Study notes. Copyright (C) 1985; The Zondervan Corporation.

Labels: , ,

Saturday, August 15, 2009

Not familiar with Kutless? Here is where to start.

The guys at Plinky.com asked the question "what three songs by the same artist would you recommend to someone who has not heard them. I chose one of my favourite artists, Kutless.


Shut Me Out by Kutless

At times, some people question whether the attitude of rock music, and the attitude of Christianity really work together. This song shows how they certainly can. This is a hard-hitting rock song, yet at its heart, the lyrics are about an undying devotion and committment to follow Jesus, no matter what.

Sea of Faces by Kutless

Demonstrating the musical diversity of Kutless, this song is musically worlds apart from 'Shut me Out'. It is a sedate song of worship and intense gratitude to God for what he has done. Its lyrics speak of recognising our true identity, and the salvation that we have received as a gift. This song would not be out of place in a communion talk during a church service.

Your Touch by Kutless

The song 'Your Touch' exists in a place where 'Shut me Out' and 'Sea of Faces' meet. Musically, it is an intense hard rock song, yet the lyrics focus on a worshipful acknowledgement of dependance upon God. This is one powerful song.