Sorry, put my elbow on the keyboard there. Here's the whole thing:
----------
I'm doing some automation to Word from Access.
In the code I have for example:
Sub PrintInWord()
Dim oDoc As Object
Dim oWord As Object
oWord.Selection..... 'formatting the word document
oWord.Selection..... 'formatting the word document
oWord.Selection..... 'formatting the word document
oWord.Selection..... 'formatting the word document
oWord.Selection..... 'formatting the word document
End Sub
I'd like to take long, repeating sections such as the
"oWord.Selection..."-lines and put them into an external sub, so that I'd
get:
Sub PrintInWord()
Dim oDoc As Object
Dim oWord As Object
call sRunThis
End Sub
Sub sRunThis
oWord.Selection.....
oWord.Selection.....
oWord.Selection.....
oWord.Selection.....
oWord.Selection.....
End Sub
But of course this doesn't work since the object "oWord" isn't available in
the sub "sRunThis".
Is there a way to refactor this kind of code into several subs? Should I
declare something at module level and doesn't this produce overhead?
Thanks for any input.
Jesper Fjølner, Denmark