Thanks Doug but as I said I am not to hot on Word and I am unclear. The
'master' is in Word2003 and as such the line spacing is fine. It is this
master that gets copied to the individual users along with their Access
front
end. It is only when the document is opened in Word2007 that the spacing
is
wrong.
The document has to be in 2003 format as most users are still on this but
gradually more are moving over to 2007. Are you suggesting I open it in
2007
(keeping the 2003 format) correct the line spacing then save it still in
2003
format? If so, will this affect how it is formatted in 2003?
My concern is that I have a whole library of merge documents and do not
want
to have correct all of them for this issue. My idea was that when the
merging
to the document it indentifies if the word app is 2007 (e.g. if objApp.
Version >=12 then ) and if so programmatically change the style set to
'Word
2003'. This is the code in access that I currently use to open the merge
document. It is this code that I wish to revise as mentioned above:
Function fnMergeIt(strDoc As String, strTbl As String, blnOptText As
Boolean,
DocID As Integer)
On Error GoTo Err_fnMergeIt
Dim objApp As Word.Application
Dim objWord As Word.Document
Dim objStyle As Word.Style
Dim strConnection As String
Dim path As String
Dim strDataDir As String
Dim ReadOnly As Boolean
Dim PrintOnly As Boolean
ReadOnly = DLookup("[ReadOnly]", "UsystblDocuments", "[DocID] = " & DocID
&
"")
PrintOnly = DLookup("[PrintOnly]", "UsystblDocuments", "[DocID] = " &
DocID &
"")
strConnection = "DSN=MS Access Database;DBQ=" & CurrentProject.FullName &
"
;FIL=MS Access;"
strDoc = Chr$(34) & CurrentProject.path & "\" & strDoc & Chr$(34)
'Debug.Print strDoc
Set objApp = CreateObject("Word.Application")
Set objWord = objApp.Documents.Open(strDoc, , ReadOnly, , , , ,
"Document")
' Set the mail merge data source
objWord.MailMerge.OpenDataSource _
Name:=CurrentProject.FullName, _
LinkToSource:=True, _
Connection:=strConnection, _
ReadOnly:=True, _
SQLStatement:="SELECT * FROM [" & strTbl & "]"
objWord.MailMerge.ViewMailMergeFieldCodes = False
' Check and action optional text
If blnOptText = True Then
For Each objStyle In objWord.Styles
If objStyle.NameLocal = "EEConfOpt" Then
With objStyle.Font
.Hidden = fnOptionalText(objStyle.NameLocal, DocID)
End With
End If
Next objStyle
objWord.UpdateStyles
End If
If PrintOnly = False Then
' Make Word visible.
objApp.Visible = True
objApp.Activate
Else
objApp.Visible = False
objWord.Save
objWord.Close
objApp.Quit
End If
Exit_fnMergeIt:
Set objWord = Nothing
Set objApp = Nothing
Exit Function
Err_fnMergeIt:
If Err.Number = 5922 Then
objWord.Close False
objApp.Quit
End If
objWord.Close False
objApp.Quit
MsgBox "fnMergeIt: " & Err.Number & " - " & Err.Description, ,
p_strSSLProduct
Resume Exit_fnMergeIt
End Function
All help and advice appreciated.
--
Darren
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.aspx/word-programming/200904/1