clvestin
12-21-2005, 07:33 AM
From Excel, I prepare a small Word memo
Public Sub Memo()
Dim a As Integer, b As Integer, c As Integer, d As Integer
Dim WordApp As Object
Dim myrange1 As Object, myrange2 As Object
Dim wordDoc As Object
Set WordApp = CreateObject("Word.Application")
SaveAsName = ThisWorkbook.Path & "\" & "wren" _
& Format(Date, "mmddyyyy") & ".doc"
With WordApp
.documents.Add
Set wordDoc = WordApp.activedocument
With .Selection
.Font.Size = 14
.Font.Bold = True
.paragraphformat.Alignment = 1
.typetext Text:="MY REPORT"
.typeparagraph
.typeparagraph
.Font.Size = 12
.paragraphformat.Alignment = 0
.Font.Bold = False
.typetext Text:="Date:" & vbTab & _
Format(Date, "mmmm d, yyyy")
Obviosly not the whole routine, but as Word is set as an object, this would be an example of late binding.
so when i use
Public Sub Memo()
Dim a As Integer, b As Integer, c As Integer, d As Integer
Dim WordApp As Word.Application
Dim myrange1 As Object, myrange2 As Object
Dim wordDoc As Word.Document
Set WordApp = New Word.Application
SaveAsName = ThisWorkbook.Path & "\" & "wren" _
& Format(Date, "mmddyyyy") & ".doc"
With WordApp
.documents.Add
Set wordDoc = WordApp.activedocument
With .Selection
.Font.Size = 14
.Font.Bold = True
.paragraphformat.Alignment = 1
.typetext Text:="MY REPORT"
.typeparagraph
.typeparagraph
.Font.Size = 12
.paragraphformat.Alignment = 0
.Font.Bold = False
.typetext Text:="Date:" & vbTab & _
Format(Date, "mmmm d, yyyy")
I would have expected this example of "very early" binding to execute significantly quicker, but I was disappointed. Any ideas as to why. Is my binding strategy flawed in some way? I have set the reference to Word.
Public Sub Memo()
Dim a As Integer, b As Integer, c As Integer, d As Integer
Dim WordApp As Object
Dim myrange1 As Object, myrange2 As Object
Dim wordDoc As Object
Set WordApp = CreateObject("Word.Application")
SaveAsName = ThisWorkbook.Path & "\" & "wren" _
& Format(Date, "mmddyyyy") & ".doc"
With WordApp
.documents.Add
Set wordDoc = WordApp.activedocument
With .Selection
.Font.Size = 14
.Font.Bold = True
.paragraphformat.Alignment = 1
.typetext Text:="MY REPORT"
.typeparagraph
.typeparagraph
.Font.Size = 12
.paragraphformat.Alignment = 0
.Font.Bold = False
.typetext Text:="Date:" & vbTab & _
Format(Date, "mmmm d, yyyy")
Obviosly not the whole routine, but as Word is set as an object, this would be an example of late binding.
so when i use
Public Sub Memo()
Dim a As Integer, b As Integer, c As Integer, d As Integer
Dim WordApp As Word.Application
Dim myrange1 As Object, myrange2 As Object
Dim wordDoc As Word.Document
Set WordApp = New Word.Application
SaveAsName = ThisWorkbook.Path & "\" & "wren" _
& Format(Date, "mmddyyyy") & ".doc"
With WordApp
.documents.Add
Set wordDoc = WordApp.activedocument
With .Selection
.Font.Size = 14
.Font.Bold = True
.paragraphformat.Alignment = 1
.typetext Text:="MY REPORT"
.typeparagraph
.typeparagraph
.Font.Size = 12
.paragraphformat.Alignment = 0
.Font.Bold = False
.typetext Text:="Date:" & vbTab & _
Format(Date, "mmmm d, yyyy")
I would have expected this example of "very early" binding to execute significantly quicker, but I was disappointed. Any ideas as to why. Is my binding strategy flawed in some way? I have set the reference to Word.