Hi,

I have some (6) .tif file in a particular folder (C:\Temp) and for each of these .tif files, I am fetching a particular column (Description) from Table X of an Oracle DB. These .tif files have been broken down to single page .tif and for some (5) .tif files the Description column has value as (Description A) and the last (6th) file (Description B).
I need to display in the header of the word file based on the .tif files their respective Description.
It would be grat if someone could help me out with this.
Please find below the code for the same:

Sub Header()

Dim Directory As String
Dim FType As String
Dim FName As String
Dim ColCount As Integer, J As Integer, TtlPgs As Integer
Dim oCn1 As ADODB.Connection
Dim oRs1 As ADODB.Recordset
Dim connection1 As String
Dim sSQLStmt As String, sSQLStmt1 As String, sSQLStmt2 As String
Dim sSplit As String
Dim Docket_Desc As Variant, v_tmp As Variant
Dim Sub_Number As String
Dim sect As Section
Dim rng As Range
Dim SelectedText As String

Directory = "c:\temp"
FType = "*.tif"

'Connecting to DB
connection1 = "Provider=MSDAORA.1;" & _
"Password=scl_edms;" & _
"User ID=scl_edms;" & _
"Data Source=snoco"

Set oCn1 = New ADODB.Connection
oCn1.Open connection1
'End of Connnection to DB

With Application
.FileSearch.FileName = FType
.FileSearch.LookIn = Directory
.FileSearch.Execute

If .FileSearch.FoundFiles.Count > 0 Then
Documents.Add
End If

For J = 1 To .FileSearch.FoundFiles.Count
FName = .FileSearch.FoundFiles(J)

With Selection.Font
.Name = "Arial"
.Size = 10
.Bold = True
End With

sSplit = Mid$(FName, Len(Directory) + 2)

'Query to get Docket Description and Sub Doc Number from Docket
sSQLStmt1 = " select dk.docket_description, dk.SUB_NUMBER, i.filename "
sSQLStmt1 = sSQLStmt1 + " from hv_user.hvimages i, hv_user.hvdocument d, hv_user.hvdocsec s,
hv_user.hvvolume v , scl_edms.docket dk "
sSQLStmt1 = sSQLStmt1 + " where dk.docid = d.docid and d.docid = s.docid and s.secid = i.secid and i.volid = v.volid"
sSQLStmt1 = sSQLStmt1 + " and i.filename = '" + sSplit + "' "

Set oRs1 = oCn1.Execute(sSQLStmt1)

Docket_Desc = oRs1.Fields("docket_description").Value
Sub_Number = oRs1.Fields("sub_number").Value
CompareTif = oRs1.Fields("filename").Value

'End of Docket Information Retrieval


Selection.TypeText Text:=Docket_Desc
Selection.TypeText Text:=vbCrLf
Selection.TypeText Text:=sSplit

Selection.InlineShapes.AddPicture FileName:=FName, _
LinkToFile:=False, SaveWithDocument:=True
Selection.ParagraphFormat.Alignment = wdAlignParagraphCenter
Selection.TypeParagraph
Selection.InsertBreak Type:=wdSectionBreakNextPage

'Display Title in header

.ActiveDocument.Sections(1).Headers(wdHeaderFooterPrimary).Range.Text = Docket_Desc

'End of display in footer

Next J
End With
End Sub

Thanks,
rkshah_78