I created a custom merge engine that inserts text from a database entry. The entire macro uses a large DOTM file with about 40 class and regular modules.
When I insert one of the fields in my final document the text reverts to 12 point even though the location in Word where I have placed my merge code is set to 14 point Bold.
I believe I can correct this issue by modifying my class file to convert the string to font size 14 before it gets inserted into my document.
attached are the modules I use to perform these functions. The class that does the work is attached. Inside this class module I have formatting other items in varying ways.
Bottom line is does anyone know a way to take a text string and change the font size without using Selection. The string in question is a large paragraph with multiple sentences.
The specific Get Function is ADA (from the attached cldRASDataElements) and here is the function code that opens the database and assigns the paragraph in question to a string called strADA.
I need to be able to convert the strADA to Times New Roman 14 Bold inside this function. Any ideas????
____________________________________________________________________________________________________ _______________
Public Function Get_ADA(ByVal strFileNumber As String) As String
' Declaring Variables
Dim dbBlueTrack As New clsDatabase
Dim rtnSet As ADODB.Recordset
Dim strADA As String, strSQLQuery As String, strErrors As String
' Open the BlueTrack database.
dbBlueTrack.SqlDialect = SqlServer
dbBlueTrack.ConnectionString = _
"Driver={SQL Server};Server=SQL2;Database=RMCMS;Uid=********;Pwd=**********;"
If Not dbBlueTrack.Connect() Then
strErrors = dbBlueTrack.ProcessADOErrors()
Call MsgBox(strErrors, vbCritical, "Database Connection Error")
Exit Function
End If
' Query database for ADA language.
strSQLQuery = "SELECT C.ADA "
strSQLQuery = strSQLQuery & "FROM County C Inner Join Tracker T ON "
strSQLQuery = strSQLQuery & "T.CountyID = C.CountyID "
strSQLQuery = strSQLQuery & "WHERE (T.FileNumber = '" & strFileNumber & "')"
Set rtnSet = dbBlueTrack.OpenRecordset(strSQLQuery)
If rtnSet Is Nothing Then
strErrors = dbBlueTrack.ProcessADOErrors()
Call MsgBox(strErrors, vbCritical, "Database Query Error")
Exit Function
End If
If rtnSet Is Nothing Then
strErrors = dbBlueTrack.ProcessADOErrors()
Call MsgBox(strErrors, vbCritical, "Database Query Error")
Exit Function
End If
rtnSet.MoveFirst
strADA = rtnSet.Fields("ADA").Value
' Close the RecordSet
rtnSet.Close
Set rtnSet = Nothing
' Close the Database
dbBlueTrack.Disconnect
Set dbBlueTrack = Nothing
' Return the ADA Language !!!! WHERE I NEED TO BE ABLE TO CONVERT TO TIMES 14 BOLD!!
Get_ADA = strADA
End Function
____________________________________________________
The Get ADA = strADA is where the paragraph is assigned to the string
When I insert one of the fields in my final document the text reverts to 12 point even though the location in Word where I have placed my merge code is set to 14 point Bold.
I believe I can correct this issue by modifying my class file to convert the string to font size 14 before it gets inserted into my document.
attached are the modules I use to perform these functions. The class that does the work is attached. Inside this class module I have formatting other items in varying ways.
Bottom line is does anyone know a way to take a text string and change the font size without using Selection. The string in question is a large paragraph with multiple sentences.
The specific Get Function is ADA (from the attached cldRASDataElements) and here is the function code that opens the database and assigns the paragraph in question to a string called strADA.
I need to be able to convert the strADA to Times New Roman 14 Bold inside this function. Any ideas????
____________________________________________________________________________________________________ _______________
Public Function Get_ADA(ByVal strFileNumber As String) As String
' Declaring Variables
Dim dbBlueTrack As New clsDatabase
Dim rtnSet As ADODB.Recordset
Dim strADA As String, strSQLQuery As String, strErrors As String
' Open the BlueTrack database.
dbBlueTrack.SqlDialect = SqlServer
dbBlueTrack.ConnectionString = _
"Driver={SQL Server};Server=SQL2;Database=RMCMS;Uid=********;Pwd=**********;"
If Not dbBlueTrack.Connect() Then
strErrors = dbBlueTrack.ProcessADOErrors()
Call MsgBox(strErrors, vbCritical, "Database Connection Error")
Exit Function
End If
' Query database for ADA language.
strSQLQuery = "SELECT C.ADA "
strSQLQuery = strSQLQuery & "FROM County C Inner Join Tracker T ON "
strSQLQuery = strSQLQuery & "T.CountyID = C.CountyID "
strSQLQuery = strSQLQuery & "WHERE (T.FileNumber = '" & strFileNumber & "')"
Set rtnSet = dbBlueTrack.OpenRecordset(strSQLQuery)
If rtnSet Is Nothing Then
strErrors = dbBlueTrack.ProcessADOErrors()
Call MsgBox(strErrors, vbCritical, "Database Query Error")
Exit Function
End If
If rtnSet Is Nothing Then
strErrors = dbBlueTrack.ProcessADOErrors()
Call MsgBox(strErrors, vbCritical, "Database Query Error")
Exit Function
End If
rtnSet.MoveFirst
strADA = rtnSet.Fields("ADA").Value
' Close the RecordSet
rtnSet.Close
Set rtnSet = Nothing
' Close the Database
dbBlueTrack.Disconnect
Set dbBlueTrack = Nothing
' Return the ADA Language !!!! WHERE I NEED TO BE ABLE TO CONVERT TO TIMES 14 BOLD!!
Get_ADA = strADA
End Function
____________________________________________________
The Get ADA = strADA is where the paragraph is assigned to the string