Add Table on the Header of a Word File. (1 Viewer)

namu

Registered User.
Local time
Today, 01:21
Joined
Dec 30, 2014
Messages
26
Hello,

Please, can anyone help me with this? I am trying to add a Table on the header of a word document but i can't figure out the proper way to do it.

The code below creates a table but it is created in the body of the word document not on the header. Please help.

I am using the below code in my Ms Access application:

Code:
Sub AddHeaderWithTable()
Dim Doc

Dim intX As Integer
Dim intY As Integer

Dim i As Integer


Dim docToOpen As FileDialog
Set docToOpen = Application.FileDialog(msoFileDialogFilePicker)
    docToOpen.Show

For i = 1 To docToOpen.SelectedItems.Count
'Open each document
Set Doc = Documents.Open(filename:=docToOpen.SelectedItems(i))
   
Set myRange = ActiveDocument.Range(Start:=0, End:=0)
ActiveDocument.Sections(1).Headers(wdHeaderFooterPrimary).Range.Tables.Add Range:=myRange, NumRows:=2, NumColumns:=3
    
Doc.Save
Doc.Close

Next i

End Sub
 
Last edited:

eshai

Registered User.
Local time
Today, 11:21
Joined
Jul 14, 2015
Messages
193
header in word insert manually
try this code


Code:
DoCmd.OutputTo ObjectType:=("tablename")AcOutputObjectType, ObjectName:=, OutputFormat:=acFormatRTF, OutputQuality:=acExportQualityPrint, =acPageHeader
 

Users who are viewing this thread

Top Bottom