Ive spent the past couple weeks kinda seeing what was out there, having minimal programming experience made it kind of difficult. However, I feel I have come up with a better way to print things to a file. Currently, I am printing to notepad, but I think it can easily be changed to word.
I used 2 access test tables to look at the feasibility of doing it 'my way'.
The structure is as follows:
+Table1
Table1ID
Table1Field
+Table2
Table2ID
Table2Field
Using VBScript, I inserted the following code into a button.
Sub CTRL129_21_OnClick(eventObj)
Const iTempFolder = 2
Dim oFS, oTempFolder, sFile, oTempFile, wshShell
Dim sRun, sTemp
Set oFS = CreateObject("Scripting.FileSystemObject")
Set oTempFolder = oFS.GetSpecialFolder(iTempFolder)
sFile = oFS.GetTempName
sTemp = oFS.GetSpecialFolder(iTempFolder)
If Right(sTemp,1) <> "\" Then
sTemp = sTemp & "\" & sFile
Else
sTemp = sTemp & sFile
End If
Set oTempFile = oTempFolder.CreateTextFile(sFile)
dim activeNode, numberNodesL1, numberNodesL2
numberNodesL1 = XDocument.DOM.selectNodes("//d:Table1").length
for i = 1 to numberNodesL1
activeNode = "//d:Table1[" & i & "]/"
oTempFile.WriteLine XDocument.DOM.selectSingleNode(activeNode & "@Table1Field").text
numberNodesL2 = XDocument.DOM.selectNodes(activeNode & "/d:Table2").length
for j = 1 to numberNodes2
activeNode = "//d:Table1[" & i & "]/d:Table2[" & j & "]/"
oTempFile.WriteLine " " + XDocument.DOM.selectSingleNode(activeNode & "@Table2Field").text
next
next
Set wshShell = Createobject("WScript.Shell")
sRun = "notepad.exe " & sTemp
wshShell.Run sRun
wshShell.AppActivate "NotePad"
End Sub
This code was written for two tables, but can easily be extended indefinatly by adding a numberNodesL variable and coding in a new for loop.
In my humble opinion, much much easier than the Word wizard.
Oh, and by the way, YOU'RE welcome - a little SNL humor there.