-
Word Automation
Hi
This is Nathan.S. I had one problem while automating word document. I have a word document with one table (actually this a document generated by output to rtf from MS Access database). I have to insert one line (report heading) in the top of the document. Problem is when I try to insert a line its getting inserted in the first cell of the table. So please help me in solving this problem. I have attached the following two documents with this.Thanks in advance.
This is the original document generated from MS Access. We have to add one or two lines in the top of the document.
This is the final document after adding the heading.
-
Try this.
[VBA] Selection.GoTo What:=wdGoToHeading, Which:=wdGoToFirst
Selection.SplitTable
[/VBA]
-
Hi Nathan,
Expanding on DRJ's solution with recorded steps
[VBA] Option Explicit
Sub MacroAddHeading()
Selection.GoTo What:=wdGoToHeading, Which:=wdGoToFirst
Selection.SplitTable
Selection.TypeParagraph
Selection.TypeParagraph
Selection.TypeParagraph
Selection.TypeParagraph
Selection.HomeKey Unit:=wdStory
Selection.MoveDown Unit:=wdLine, Count:=1, Extend:=wdExtend
Selection.Font.Bold = True
Selection.Font.Size = 16
Selection.TypeText Text:=InputBox("Document Heading")
Selection.MoveDown Unit:=wdLine, Count:=2
Selection.MoveRight Unit:=wdCharacter, Count:=1, Extend:=wdExtend
Selection.Font.Bold = True
Selection.Font.Size = 12
Selection.TypeText Text:="Date: "
Selection.InsertDateTime DateTimeFormat:="dd/MM/yy", InsertAsField:=False, _
DateLanguage:=wdEnglishUK, CalendarType:=wdCalendarWestern, _
InsertAsFullWidth:=False
Selection.HomeKey Unit:=wdStory
End Sub
[/VBA]
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules