J
JWS315
I am trying to use Word via Visio to produce a document. I will not know
what version of Word users will have so I have tried to use the following
code and get an error variable not found on the following lines
docFinal.PageSetup.Orientation = wdOrientPortrait
..ParagraphFormat.Alignment = wdAlignParagraphCenter
wdApp.Selection.EndKey unit:=wdStory
Below is the code I am using - Any Help would be greatly appreciated!
Jerry
Function CreateWordDoc(ByVal strType As Integer)
Dim strFilter As String
Dim fname As String
Dim message As String
Dim Response As String
Dim wdFname As String
Dim docFinal As Object
Dim myRange As Object
Dim runDate As String
Dim docRange As Object
Dim intConnect As Integer
Dim intFromToConnect As Integer
Dim strTitle As String
Dim wdApp As Object
On Error GoTo CreateWordDoc_Error
Const ERR_APP_NOTFOUND As Long = 429
' Attempt to create late-bound instance of Word application to determine if
installed
Set wdApp = CreateObject("Word.Application")
If Err.Number = ERR_APP_NOTFOUND Then
MsgBox "Word is not installed on this computer, No reports can be
generated", vbExclamation, "Word Not Installed"
wdApp.Quit
Exit Function
End If
wdApp.Visible = True
Set docFinal = wdApp.Documents.Add
docFinal.PageSetup.Orientation = wdOrientPortrait
docFinal.PageSetup.DifferentFirstPageHeaderFooter = False
runDate = Format(Date, "mmmm, yyyy")
Select Case strType
Case 1
strTitle = "Process descriptions by Location for"
Case 2
strTitle = "Process descriptions by Role for"
End Select
'Insert a title page
Set myRange = wdApp.Selection.Range
With myRange
.ParagraphFormat.Alignment = wdAlignParagraphCenter
.InsertAfter strTitle & vbCrLf & " " & vbCrLf & ""
.InsertAfter strMapName & vbCrLf & " " & vbCrLf & " " & vbCrLf & ""
.InsertAfter " " & vbCrLf & " " & vbCrLf & ""
.Font.Size = "24"
.Italic = True
.Font.Name = "arial"
.Bold = True
End With
wdApp.Selection.EndKey unit:=wdStory
Set myRange = wdApp.Selection.Range
With myRange
.InsertAfter "" & runDate & ""
.InsertAfter " " & vbCrLf & " " & vbCrLf & " " & vbCrLf & " " &
vbCrLf & ""
.Font.Size = "18"
.Font.Name = "arial"
.Bold = False
End With
wdApp.Selection.EndKey unit:=wdStory
what version of Word users will have so I have tried to use the following
code and get an error variable not found on the following lines
docFinal.PageSetup.Orientation = wdOrientPortrait
..ParagraphFormat.Alignment = wdAlignParagraphCenter
wdApp.Selection.EndKey unit:=wdStory
Below is the code I am using - Any Help would be greatly appreciated!
Jerry
Function CreateWordDoc(ByVal strType As Integer)
Dim strFilter As String
Dim fname As String
Dim message As String
Dim Response As String
Dim wdFname As String
Dim docFinal As Object
Dim myRange As Object
Dim runDate As String
Dim docRange As Object
Dim intConnect As Integer
Dim intFromToConnect As Integer
Dim strTitle As String
Dim wdApp As Object
On Error GoTo CreateWordDoc_Error
Const ERR_APP_NOTFOUND As Long = 429
' Attempt to create late-bound instance of Word application to determine if
installed
Set wdApp = CreateObject("Word.Application")
If Err.Number = ERR_APP_NOTFOUND Then
MsgBox "Word is not installed on this computer, No reports can be
generated", vbExclamation, "Word Not Installed"
wdApp.Quit
Exit Function
End If
wdApp.Visible = True
Set docFinal = wdApp.Documents.Add
docFinal.PageSetup.Orientation = wdOrientPortrait
docFinal.PageSetup.DifferentFirstPageHeaderFooter = False
runDate = Format(Date, "mmmm, yyyy")
Select Case strType
Case 1
strTitle = "Process descriptions by Location for"
Case 2
strTitle = "Process descriptions by Role for"
End Select
'Insert a title page
Set myRange = wdApp.Selection.Range
With myRange
.ParagraphFormat.Alignment = wdAlignParagraphCenter
.InsertAfter strTitle & vbCrLf & " " & vbCrLf & ""
.InsertAfter strMapName & vbCrLf & " " & vbCrLf & " " & vbCrLf & ""
.InsertAfter " " & vbCrLf & " " & vbCrLf & ""
.Font.Size = "24"
.Italic = True
.Font.Name = "arial"
.Bold = True
End With
wdApp.Selection.EndKey unit:=wdStory
Set myRange = wdApp.Selection.Range
With myRange
.InsertAfter "" & runDate & ""
.InsertAfter " " & vbCrLf & " " & vbCrLf & " " & vbCrLf & " " &
vbCrLf & ""
.Font.Size = "18"
.Font.Name = "arial"
.Bold = False
End With
wdApp.Selection.EndKey unit:=wdStory