Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 550
Default Early vs Late Binding - Word

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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Early vs Late Binding - Word

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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Early vs Late Binding - Word

Read this John

http://www.erlandsendata.no/english/...baoleolebasics

--
Regards Ron de Bruin
(Win XP Pro SP-1 XL2002 SP-2)
www.rondebruin.nl



"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



  #4   Report Post  
Posted to microsoft.public.excel.programming
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


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 550
Default Early vs Late Binding - Word

Ron,

Thanks for that.
I did read it.
There are actually some very detailed threads in Google on the subject
and I've perused many of them too.
I don't usually ask "homework" type questions, but I was in a bind
(an early bind), since I have multiple users sharing files with
different versions of Office and I've been running around setting
and resetting object references all day.
I have everything running okay now on the old version PC's and the new
ones are off limits (under pain of death) until I can get this resolved.

Thanks,
John


Ron de Bruin wrote:

Read this John

http://www.erlandsendata.no/english/...baoleolebasics

--
Regards Ron de Bruin
(Win XP Pro SP-1 XL2002 SP-2)
www.rondebruin.nl

"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




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 860
Default Early vs Late Binding - Word

Hi John,

Since you're using Late Binding now, you must be sure to replace all named
constants with their actual values. VBA has no idea what wdGoToBookmark is,
so you should use -1 instead. You can get the value by going into Word,
opening the VBE, and typing ?wdGoToBookmark in the immediate window.

BTW, you should use Option Explicit at the top of each module - that way,
you would be warned that wdGoToBookmark is undefined.

--
Regards,

Jake Marx
MS MVP - Excel
www.longhead.com

[please keep replies in the newsgroup - email address unmonitored]


John Wilson wrote:
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


  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 550
Default Early vs Late Binding - Word

Jake,

That did the trick!!!
Thanks for the help.

you should use Option Explicit at the top of each module

As a rule, I usually do. I had it commented out whilst working
on this problem.

Thanks again,
John

Jake Marx wrote:

Hi John,

Since you're using Late Binding now, you must be sure to replace all named
constants with their actual values. VBA has no idea what wdGoToBookmark is,
so you should use -1 instead. You can get the value by going into Word,
opening the VBE, and typing ?wdGoToBookmark in the immediate window.

BTW, you should use Option Explicit at the top of each module - that way,
you would be warned that wdGoToBookmark is undefined.

--
Regards,

Jake Marx
MS MVP - Excel
www.longhead.com

[please keep replies in the newsgroup - email address unmonitored]

John Wilson wrote:
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


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Late Binding issue with Excel.Application object [email protected][_2_] Excel Discussion (Misc queries) 2 August 4th 09 08:10 AM
Late binding to Excel from Access causing Object error EagleOne@microsoftdiscussiongroups[_2_] Excel Discussion (Misc queries) 4 June 14th 08 12:45 AM
Formula that returns late, early or Ok accordingly to the period leslieyosbe Excel Discussion (Misc queries) 2 August 3rd 06 05:36 PM
VB Extensibility library and "late binding" Dennis Excel Discussion (Misc queries) 0 March 30th 05 10:51 PM
DAO objects with late binding in Excel? Chris Excel Programming 0 August 21st 03 07:28 PM


All times are GMT +1. The time now is 11:12 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"