Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.word.tables
|
|||
|
|||
table replaces text already typed...
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! -- MorningStarFan |
#2
Posted to microsoft.public.word.tables
|
|||
|
|||
table replaces text already typed...
nevermind, I found it!
See code below... I needed to set the range for this section of the document...so I added this and it works! Set oRange = .Sections(1).Range With oRange .MoveEnd Unit:=wdCharacter, Count:=-1 .Collapse Direction:=wdCollapseEnd .InsertParagraphAfter .InsertAfter "End of section" End With -- MorningStarFan "MorningStarFan" wrote: 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! -- MorningStarFan |
#3
Posted to microsoft.public.word.tables
|
|||
|
|||
table replaces text already typed...
nevermind, I found it!
See code below... I needed to set the range for this section of the document...so I added this and it works! Set oRange = .Sections(1).Range With oRange .MoveEnd Unit:=wdCharacter, Count:=-1 .Collapse Direction:=wdCollapseEnd .InsertParagraphAfter .InsertAfter "End of section" End With -- -- MorningStarFan "MorningStarFan" wrote: 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! -- MorningStarFan |
Reply |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
How can I swap all the table data in column #5 so it replaces col | Tables | |||
Locking Cells in a Table So They Cannot Be Typed In | Tables | |||
How do I create a table of contents with my document already typed | Page Layout | |||
adding text to doc deletes remaining text as typed. | Microsoft Word Help | |||
text typed in the middle of a word doc. replaces text | Microsoft Word Help |