M
MorningStarFan
I am using MS Office 2003. I'm creating a button on a form in Access that
when clicked will run vba code that creates a word document. I am trying to
convert one string of text in my code to a table. However when I do this the
table replaces my text that I've already created in my document. Can anyone
tell why? I hope this code is legible in this post...
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!
when clicked will run vba code that creates a word document. I am trying to
convert one string of text in my code to a table. However when I do this the
table replaces my text that I've already created in my document. Can anyone
tell why? I hope this code is legible in this post...
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!