Helen Pippard
New Member
- Joined
- Dec 12, 2008
- Messages
- 47
Hello,
I have a Function in VBA which is "too large" to run
So what I have done is taken a huge chunk of the procedure and created a seperate function which I need to CALL back into my main function
The original syntex read as:
m_objDoc.Bookmarks("COUNT_DPED_COLECTOMY").Select
m_objWord.Selection.Text = Switch(IsNull(DLookup("[COUNT]", "COUNT_DPED_COLECTOMY")) = True, "", True, Round(DLookup("[COUNT]", "COUNT_DPED_COLECTOMY")))
This took a value from a table and exported the data into my bookmark in MS.word, but as I am repeating this process over 100 times the procedure became too large
I created a new function called:
SetVariablesForSwitch(StrVariable As String)
In this function I declared my variables and did all the switch statements
Now I do not know how to CALL the function correctly in my main function. I currently have it set as
m_objDoc.Bookmarks("COUNT_DPED_COLECTOMY").Select
m_objWord.Selection.Text = StrVariable = SetVariablesForSwitch("StrCOUNT_DPED_COLECTOMY")
All this returns is a TRUE in my word document.
Question
I need to know what correct VBA to use in order to call my sub funtion correctly and so it can recognise that what I am calling is a variable and I want it to export the value into my bookmark in MS.word
Any suggestions?
Thanks for any help?
Helen
I have a Function in VBA which is "too large" to run
So what I have done is taken a huge chunk of the procedure and created a seperate function which I need to CALL back into my main function
The original syntex read as:
m_objDoc.Bookmarks("COUNT_DPED_COLECTOMY").Select
m_objWord.Selection.Text = Switch(IsNull(DLookup("[COUNT]", "COUNT_DPED_COLECTOMY")) = True, "", True, Round(DLookup("[COUNT]", "COUNT_DPED_COLECTOMY")))
This took a value from a table and exported the data into my bookmark in MS.word, but as I am repeating this process over 100 times the procedure became too large
I created a new function called:
SetVariablesForSwitch(StrVariable As String)
In this function I declared my variables and did all the switch statements
Now I do not know how to CALL the function correctly in my main function. I currently have it set as
m_objDoc.Bookmarks("COUNT_DPED_COLECTOMY").Select
m_objWord.Selection.Text = StrVariable = SetVariablesForSwitch("StrCOUNT_DPED_COLECTOMY")
All this returns is a TRUE in my word document.
Question
I need to know what correct VBA to use in order to call my sub funtion correctly and so it can recognise that what I am calling is a variable and I want it to export the value into my bookmark in MS.word
Any suggestions?
Thanks for any help?
Helen