Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default late binding

I am running a macro in Office 2003 and need to run it in XP, so from what I
understand I need to uncheck the reference to word, since that is where the
merging is happening and then change the code to "late binding". My problem
is that looking at the code I can't figure out what to change. Here is the
beginning of the code:

Dim wdApp As Object
Dim myDoc As Word.Document
Set wdApp = CreateObject("Word.Application")
Set myDoc =
Word.Documents.Open("\\powervault2\home_pl\common\ Referrals\Referal Agency -
Ecology.doc")
ActiveDocument.MailMerge.MainDocumentType = wdFormLetters
ActiveDocument.MailMerge.OpenDataSource Name:= _
"\\powervault2\home_pl\common\Referrals\Referals.x ls", _

Any suggestions?


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default late binding

I changed some of the code as you recommended. I am now getting a syntax
error. I have seperated the part that is being highlighted as the error.Here
is the code:

Dim wdApp As Object
Dim myDoc As Object
Set wdApp = CreateObject("Word.Application")
Set myDoc =
wdApp.Documents.Open("\\powervault2\home_pl\common \Referrals\Referal
Agency - Ecology.doc")
With myDoc.MailMerge.MainDocumentType = wdFormLetters

The code below is where I am getting the syntax error.

With myDoc.MailMerge.OpenDataSource Name:= _
"\\powervault2\home_pl\common\Referrals\Referals.x ls", _
ConfirmConversions:=False, ReadOnly:=False, LinkToSource:=True, _
AddToRecentFiles:=False, PasswordDocument:="", PasswordTemplate:="",
_
WritePasswordDocument:="", WritePasswordTemplate:="", Revert:=False,
_
Format:=wdOpenFormatAuto, Connection:= _
"Provider=Microsoft.Jet.OLEDB.4.0;Password="""";Us er ID=Admin;Data
Source=\\powervault2\home_pl\common\Referrals\Refe rals.xls;Mode=Read;Extended
Properties=""HDR=YES;IMEX=1;"";Jet OLEDB:System database="""";Jet
OLEDB:Registry Path="""";Jet OLEDB:Database Pa" _
, SQLStatement:="SELECT * FROM `Sheet1$`", SQLStatement1:="",
SubType:= _
wdMergeSubTypeAccess



"JLatham" <HelpFrom @ Jlathamsite.com.(removethis) wrote in message
...
With 'late binding' basically everything is an Object until you actually
do
assignments with the Set statement. So you need to
Dim myDoc as Object
also. You'll need to refer to the objects instead of the application in
the
code, as instead of
Set myDoc = Word.Documents.Open(...
it becomes
Set myDoc = wdApp.Documents.Open(...
and probably a good thing in the rest would be something like:
With myDoc
.MailMerge.MainDocumentType=...
.MailMerge.OpenDatasource Name:=...
...
End With

or even
With myDoc.MailMerge
.MainDocumentType=...
.OpenDatasource Name:=...
...
End With
Whether you can use that second one depends on what else is going on with
the document besides MailMerge methods.

"Michelle Hanan" wrote:

I am running a macro in Office 2003 and need to run it in XP, so from
what I
understand I need to uncheck the reference to word, since that is where
the
merging is happening and then change the code to "late binding". My
problem
is that looking at the code I can't figure out what to change. Here is
the
beginning of the code:

Dim wdApp As Object
Dim myDoc As Word.Document
Set wdApp = CreateObject("Word.Application")
Set myDoc =
Word.Documents.Open("\\powervault2\home_pl\common\ Referrals\Referal
Agency -
Ecology.doc")
ActiveDocument.MailMerge.MainDocumentType = wdFormLetters
ActiveDocument.MailMerge.OpenDataSource Name:= _
"\\powervault2\home_pl\common\Referrals\Referals.x ls", _

Any suggestions?





  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default late binding

Michelle,
Also with late binding you cannot use the declared constants/enums e.g.
wdFormLetters
You need to check the Help and/or Object Browser to find their actual
values, in this case 0.
Or declare it yourself:
Const wdFormLetters = 0

Another thing to look for is the addition of functionality or additional
arguments that is not present in the earlier version.
Functionality will obviously not be present, so you can't use it. Find a
different method.
Additional arguments are usually optional, so you can delete them.
You would have to check the documentation on the methods for each supported
version to determine this.

NickHK

"Michelle Hanan" wrote in message
...
I am running a macro in Office 2003 and need to run it in XP, so from what

I
understand I need to uncheck the reference to word, since that is where

the
merging is happening and then change the code to "late binding". My

problem
is that looking at the code I can't figure out what to change. Here is the
beginning of the code:

Dim wdApp As Object
Dim myDoc As Word.Document
Set wdApp = CreateObject("Word.Application")
Set myDoc =
Word.Documents.Open("\\powervault2\home_pl\common\ Referrals\Referal

Agency -
Ecology.doc")
ActiveDocument.MailMerge.MainDocumentType = wdFormLetters
ActiveDocument.MailMerge.OpenDataSource Name:= _
"\\powervault2\home_pl\common\Referrals\Referals.x ls", _

Any suggestions?




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 examples of binding excel application HeatherO Excel Programming 13 March 17th 05 08:19 AM
Late Binding Todd Huttenstine[_3_] Excel Programming 3 April 30th 04 11:01 AM
Late Binding Cindy Excel Programming 11 April 23rd 04 03:34 PM
EARLY binding or LATE binding ? jason Excel Programming 6 February 26th 04 04:57 PM
DAO Late Binding? Sharqua Excel Programming 2 January 4th 04 02:05 AM


All times are GMT +1. The time now is 02:41 AM.

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"