View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
John Wilson John Wilson is offline
external usenet poster
 
Posts: 550
Default Early vs Late Binding - Word

Chip,

Thanks for that.
I guess I was trying to overcomplicate things.
Anyway, your suggestion worked perfectly and many thanks.

I have one more associated dilemma, though.
Using your suggestion, the correct word document does open.
This line of code crashes though (it worked with early binding)

Set wordRange = wordDoc.Goto(What:=wdGoToBookmark, Name:="FaxTo")
The error that I get is that "This bookmark does not exist", but it does indeed
exist.

For reference, the coding per your suggestion that did work is as follows:
Dim wordApp As Object
Dim wordDoc As Object
Dim wordRange As Object
Dim FileNameAndPath As String
FileNameAndPath = ActiveWorkbook.path & "\Forms\Fax_Cover_Master.doc"
Set wordApp = CreateObject("Word.Application")
Set wordDoc = wordApp.Documents.Open(FileNameAndPath, ReadOnly:=True)

Again...many thanks,
John




Chip Pearson wrote:

John,

Just change all the declarations for Word objects from "As Word.whatever" to
"As Object".

--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com

"John Wilson" wrote in message
...
I'm finally getting a taste (quite sour) of Office 2003.
It came with the two new PC's so I didn't have much of a choice.
In many (actually all) of the workbooks where I interact with Word,
I used Early Binding. Since the initial workbooks were created in
Office 2000, when someone with a later version saves the workbook
the Word Object reference is set to version 11.
I've already read through many of the threads by Chip, Rob, etc.
and it's beginning to sink in (but a lot slower than I would have
hoped).

Whilst still getting a handle on this, I would appreciate it if someone
could convert the following code to utilize Late Binding.
I can get some of it to work, but not all. Any help would be
appreciated.

Dim wordApp As Word.Application
Dim wordDoc As Word.Document
Dim wordRange As Word.Range
Dim FileNameAndPath As String
FileNameAndPath = ActiveWorkbook.path & "\Forms\Fax_Cover_Master.doc"
Set wordApp = CreateObject("Word.Application")
Set wordDoc = wordApp.Documents.Open(FileNameAndPath, ReadOnly:=True)

Thanks,
John