![]() |
|
|||||||
|
|
Thread Tools | Display Modes |
|
#16
|
||||
|
||||
|
Yes, the function can be called from any Sub or even another Function. It doesn't have to be an automacro.
Your other macro is getting the data from Excel as an ADODB Recordset and then converting this into an array and then finally into a string by concatenating all the array position contents into a string. So essentially you have the same content in three very different formats. The point of going all the way to a string is so you can save that in a document metadata store so it can be retrieved any time WITHOUT needing to get it fresh from Excel again. The problem with this format is that you will need to split the contents of that string to firstly break it into rows and then split each row into columns in order to get back to the contents of any single Excel cell. However, if you want to make use of the data WHILE the macro is still running, you have the choice of using it in either of the earlier formats where it is still broken up into the individual cells of data. Say you wanted to use the Recordset (recSet) to grab all the data from one field. After the recSet has been populated by the first line, you can loop through its records to grab a field Code:
Set recSet = connection.Execute(strQuery2, , adCmdText)
With recSet
.MoveFirst
Do While Not .EOF
Debug.print recSet!person_number
.MoveNext
Loop
End With
__________________
Andrew Lockton Chrysalis Design, Melbourne Australia |
| Tags |
| word fields, word vba, word vba macro |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
Reset "Button" to clear Word user-filled form, from all filled details.
|
Rafi | Word VBA | 20 | 01-20-2023 02:16 PM |
VBA to Populate text content controls in word from excel
|
lmoir87 | Word VBA | 15 | 05-27-2022 04:22 PM |
| Auto populate form (data from excel) in Word based on drop down list selection (data from excel) | wvlls | Word VBA | 1 | 03-22-2019 02:29 PM |
| Form with content controls - expands but at the bottom of the form | louiseword | Word | 3 | 05-27-2016 12:47 AM |
Date auto-populates based on checkbox
|
mcarter9000 | Word VBA | 5 | 12-23-2010 12:39 PM |