M
MorningStarFan
I am using MS Office 2003. I've created a form in Access and when I click a
button on the form some vba code runs that creates a word doc with data from
my access table. Problem is - I want to convert some of that text into a
table. I've found the syntax to do this but when the table range is set, all
my other text inserted into the doc before that disappears. Any ideas?
If Records = 1 Then
' If fund names are different do this...
If sFUND_NAME <> sNEXT_FUND_NAME Then
With .Selection
Set rs = dbs.OpenRecordset("SELECT XSA_NAME,
Und_Amount, XSA_P_CITY, XSA_P_STATE, CLASS, Major_Desc, FUND_NAME FROM
QRY_FORMAL_FUNDNAME WHERE FUND_NAME = '" & sFUND_NAME & "'", dbOpenDynaset)
Do While Not rs.EOF
irows = irows + 2
rs.MoveNext
Loop
irows = irows + 1
.ParagraphFormat.Alignment =
wdAlignParagraphCenter
.InlineShapes.AddPicture
FileName:="W:\Stewardship_Automation\New Picture.png", LinkToFile:=False, _
SaveWithDocument:=True
.TypeParagraph
.TypeParagraph
.Font.Size = 18
.ParagraphFormat.Alignment = 0
.Font.Bold = True
.Font.Italic = True
.TypeText Text:=sFUND_NAME
.TypeParagraph
.TypeParagraph
.TypeParagraph
.Font.Size = 14
.Font.Bold = True
.ParagraphFormat.Alignment =
wdAlignParagraphLeft
.TypeText Text:="2006-2007 RECIPIENT
INFORMATION"
.TypeParagraph
sTemp = sName & vbTab & cAmount & vbTab & sPCITY &
vbTab & sPSTATE & vbTab & sCLASS & vbTab & sMajor
'Insert a heading on the string
sTemp = "RECIPIENT" & vbTab & "AWARD" & vbTab &
"CITY" & vbTab & "STATE" & vbTab & "CLASS" & vbTab & "MAJOR" & vbCrLf & sTemp
'Insert the data into the word document
oRange.Text = sTemp
'Convert the text to a table and format the table
oRange.ConvertToTable vbTab, , , , wdAutoFitFixed, ,
, , , , , , , , , wdWord9TableBehavior
' .TypeText sTemp
'.ConvertToTable vbTab, , , ,
wdAutoFitFixed, , , , , , , , , , , wdWord9TableBehavior
.MoveDown Unit:=wdLine, Count:=irows
.InsertBreak Type:=wdPageBreak
End With
TIA,
button on the form some vba code runs that creates a word doc with data from
my access table. Problem is - I want to convert some of that text into a
table. I've found the syntax to do this but when the table range is set, all
my other text inserted into the doc before that disappears. Any ideas?
If Records = 1 Then
' If fund names are different do this...
If sFUND_NAME <> sNEXT_FUND_NAME Then
With .Selection
Set rs = dbs.OpenRecordset("SELECT XSA_NAME,
Und_Amount, XSA_P_CITY, XSA_P_STATE, CLASS, Major_Desc, FUND_NAME FROM
QRY_FORMAL_FUNDNAME WHERE FUND_NAME = '" & sFUND_NAME & "'", dbOpenDynaset)
Do While Not rs.EOF
irows = irows + 2
rs.MoveNext
Loop
irows = irows + 1
.ParagraphFormat.Alignment =
wdAlignParagraphCenter
.InlineShapes.AddPicture
FileName:="W:\Stewardship_Automation\New Picture.png", LinkToFile:=False, _
SaveWithDocument:=True
.TypeParagraph
.TypeParagraph
.Font.Size = 18
.ParagraphFormat.Alignment = 0
.Font.Bold = True
.Font.Italic = True
.TypeText Text:=sFUND_NAME
.TypeParagraph
.TypeParagraph
.TypeParagraph
.Font.Size = 14
.Font.Bold = True
.ParagraphFormat.Alignment =
wdAlignParagraphLeft
.TypeText Text:="2006-2007 RECIPIENT
INFORMATION"
.TypeParagraph
sTemp = sName & vbTab & cAmount & vbTab & sPCITY &
vbTab & sPSTATE & vbTab & sCLASS & vbTab & sMajor
'Insert a heading on the string
sTemp = "RECIPIENT" & vbTab & "AWARD" & vbTab &
"CITY" & vbTab & "STATE" & vbTab & "CLASS" & vbTab & "MAJOR" & vbCrLf & sTemp
'Insert the data into the word document
oRange.Text = sTemp
'Convert the text to a table and format the table
oRange.ConvertToTable vbTab, , , , wdAutoFitFixed, ,
, , , , , , , , , wdWord9TableBehavior
' .TypeText sTemp
'.ConvertToTable vbTab, , , ,
wdAutoFitFixed, , , , , , , , , , , wdWord9TableBehavior
.MoveDown Unit:=wdLine, Count:=irows
.InsertBreak Type:=wdPageBreak
End With
TIA,