Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.tables
MorningStarFan MorningStarFan is offline
external usenet poster
 
Posts: 7
Default 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   Report Post  
Posted to microsoft.public.word.tables
MorningStarFan MorningStarFan is offline
external usenet poster
 
Posts: 7
Default 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   Report Post  
Posted to microsoft.public.word.tables
MorningStarFan MorningStarFan is offline
external usenet poster
 
Posts: 7
Default 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

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How can I swap all the table data in column #5 so it replaces col Me Tables 1 July 25th 06 05:49 PM
Locking Cells in a Table So They Cannot Be Typed In jjjdel Tables 7 March 29th 06 01:27 AM
How do I create a table of contents with my document already typed 100101011101 Page Layout 1 March 4th 06 02:26 AM
adding text to doc deletes remaining text as typed. go gators Microsoft Word Help 3 October 13th 05 01:46 PM
text typed in the middle of a word doc. replaces text Bruce Teschner Microsoft Word Help 1 March 8th 05 05:32 PM


All times are GMT +1. The time now is 07:26 PM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"