![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | How to insert text in a new Word document? I am trying to generate a report (in Word) that contains text and tables. What I am doing first is to write the title (objSelection.TypeText "Report") and then to generate a table. The problem I have is that the table will overwrite the title so at the end I will have only the table. How I can avoid this? Set objWord = CreateObject("Word.Application") objWord.Visible = True Set objDoc = objWord.Documents.Add() Set objSelection = objWord.Selection objSelection.TypeParagraph() objSelection.Font.Name = "Times New Roman" objSelection.Font.Size = "18" objSelection.TypeText "Report" Set objRange = objDoc.Range() objDoc.Tables.Add objRange,1,5 Set objTable = objDoc.Tables(1) objTable.Range.Font.Size = 10 objTable.Range.Style = "Medium Grid 1 - Accent 1" objTable.Cell(x, 1).Range.Text = "h1" objTable.Cell(x, 2).Range.text = "h2" objTable.Cell(x, 3).Range.text = "h3" objTable.Cell(x, 4).Range.text = "h4" objTable.Cell(x, 5).Range.text = "h5" ….. |
My System Specs![]() |
| | #2 (permalink) |
| | RE: How to insert text in a new Word document? Never mind...my fault. I used Set objRange = objDoc.Range() instead of Set objRange = objSelection.Range "Don" wrote: Quote: > > I am trying to generate a report (in Word) that contains text and tables. > What I am doing first is to write the title (objSelection.TypeText "Report") > and then > to generate a table. > > The problem I have is that the table will overwrite the title so at the end > I will have only the table. > > How I can avoid this? > > > Set objWord = CreateObject("Word.Application") > objWord.Visible = True > Set objDoc = objWord.Documents.Add() > > Set objSelection = objWord.Selection > objSelection.TypeParagraph() > > objSelection.Font.Name = "Times New Roman" > objSelection.Font.Size = "18" > objSelection.TypeText "Report" > > Set objRange = objDoc.Range() > > objDoc.Tables.Add objRange,1,5 > Set objTable = objDoc.Tables(1) > objTable.Range.Font.Size = 10 > objTable.Range.Style = "Medium Grid 1 - Accent 1" > > objTable.Cell(x, 1).Range.Text = "h1" > objTable.Cell(x, 2).Range.text = "h2" > objTable.Cell(x, 3).Range.text = "h3" > objTable.Cell(x, 4).Range.text = "h4" > objTable.Cell(x, 5).Range.text = "h5" > ….. > > |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Converting Word 97-2003 document to Word 2007 | Vista General | |||
| Send Word document by email from Word 2003 not working with WLM | Live Mail | |||
| accidentally moved a MS Word document,now it dissapears everytime i open any word document | Vista performance & maintenance | |||
| accidentally moved a MS Word document,now it dissapears everytime i open any word document | Vista General | |||
| Creating Word document of Word 97-2003 file type on the New menu in Vista | Vista General | |||