Group:  Microsoft Word ยป microsoft.public.word.vba.beginners
Thread: Syntax error calling MailMerge.OpenDataSource

DotNetBag
.NET Development Newsgroups

HTVi
TV Discussion Newsgroups

Our Hot Pick: Rising Antivirus 2006 - Certified by TUV & Checkmark! Get 10% discount by entering this coupon code: ONDISCOUNT10
Rising Antivirus 2006

Syntax error calling MailMerge.OpenDataSource
"Laurel" <FakeMail[ at ]Hotmail.com> 31.01.2006 16:49:25
This is the only statement in a macro I've created. If I use only the first
parameter (leave off the format parameter, 0), it works fine. If I add the
zero, I get a syntax error. What am I doing wrong?

ActiveDocument.MailMerge.OpenDataSource
("C:\OpenDataSource\OpenDataSource.xls",0)



Re: Syntax error calling MailMerge.OpenDataSource
"Doug Robbins - Word MVP" <dkr[ at ]REMOVETHISmvps.org> 31.01.2006 18:54:45
Probably each of the wdOpenFormat constants does have a unique numeric
value. As I do not know what they are and therefore cannot say whether 0 is
a valid value, why not use the format that you want using its text format.
The following from the Visual Basic Help file gives the the WdOpenFormat
constants:

Format Optional Variant. The file converter used to open the document.
Can be one of the WdOpenFormat constants. To specify an external file
format, use the OpenFormat property with the FileConverter object to
determine the value to use with this argument.

WdOpenFormat can be one of these WdOpenFormat constants.
wdOpenFormatAllWord
wdOpenFormatAuto Default.
wdOpenFormatDocument
wdOpenFormatEncodedText
wdOpenFormatRTF
wdOpenFormatTemplate
wdOpenFormatText
wdOpenFormatUnicodeText
wdOpenFormatWebPages
wdOpenFormatXML


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

"Laurel" <FakeMail[ at ]Hotmail.com> wrote in message
news:Ore3RYoJGHA.344[ at ]TK2MSFTNGP11.phx.gbl...
[Quoted Text]
> This is the only statement in a macro I've created. If I use only the
> first parameter (leave off the format parameter, 0), it works fine. If I
> add the zero, I get a syntax error. What am I doing wrong?
>
> ActiveDocument.MailMerge.OpenDataSource
> ("C:\OpenDataSource\OpenDataSource.xls",0)
>
>
>


Re: Syntax error calling MailMerge.OpenDataSource
"Laurel" <FakeMail[ at ]Hotmail.com> 01.02.2006 20:22:33
Well, I tried this but still got the same error. wdOpenFormatDocument has a
value of 0.
ActiveDocument.MailMerge.OpenDataSource
("C:\OpenDataSource\OpenDataSource.xls", wdOpenFormatDocument)

I tried this and it worked.
ActiveDocument.MailMerge.OpenDataSource _
Name:="C:\OpenDataSource\OpenDataSource.xls", _
Format:=wdOpenFormatAuto

Is it actually the case that position-based parameters don't work in Word at
all? The reason this is important is that I wanted to demonstrate that the
following statement, which used to work in PowerBuilder for Word 9.0, and
which no longer works in 11.0, DOES work in a non-PowerBuilder environment.
So it's important that I be able to use positioning instead of naming.

ole_word_file.MailMerge.OpenDataSource
("C:\OpenDataSource\OpenDataSource.xls",0,FALSE,TRUE,FALSE,FALSE,"","",FALSE,"","","Entire
Spreadsheet")


"Doug Robbins - Word MVP" <dkr[ at ]REMOVETHISmvps.org> wrote in message
news:e6%23LQfpJGHA.2212[ at ]TK2MSFTNGP15.phx.gbl...
[Quoted Text]
> Probably each of the wdOpenFormat constants does have a unique numeric
> value. As I do not know what they are and therefore cannot say whether 0
> is a valid value, why not use the format that you want using its text
> format. The following from the Visual Basic Help file gives the the
> WdOpenFormat constants:
>
> Format Optional Variant. The file converter used to open the document.
> Can be one of the WdOpenFormat constants. To specify an external file
> format, use the OpenFormat property with the FileConverter object to
> determine the value to use with this argument.
>
> WdOpenFormat can be one of these WdOpenFormat constants.
> wdOpenFormatAllWord
> wdOpenFormatAuto Default.
> wdOpenFormatDocument
> wdOpenFormatEncodedText
> wdOpenFormatRTF
> wdOpenFormatTemplate
> wdOpenFormatText
> wdOpenFormatUnicodeText
> wdOpenFormatWebPages
> wdOpenFormatXML
>
>
> --
> Hope this helps.
>
> Please reply to the newsgroup unless you wish to avail yourself of my
> services on a paid consulting basis.
>
> Doug Robbins - Word MVP
>
> "Laurel" <FakeMail[ at ]Hotmail.com> wrote in message
> news:Ore3RYoJGHA.344[ at ]TK2MSFTNGP11.phx.gbl...
>> This is the only statement in a macro I've created. If I use only the
>> first parameter (leave off the format parameter, 0), it works fine. If I
>> add the zero, I get a syntax error. What am I doing wrong?
>>
>> ActiveDocument.MailMerge.OpenDataSource
>> ("C:\OpenDataSource\OpenDataSource.xls",0)
>>
>>
>>
>
>


Re: Syntax error calling MailMerge.OpenDataSource
"Doug Robbins - Word MVP" <dkr[ at ]REMOVETHISmvps.org> 02.02.2006 19:24:55
Sorry, I don't know.

However, that's the first indication that I have seen of PowerBuilder
working with anything. There's certainly been a lot of people come to these
newsgroups with problems with it.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

"Laurel" <FakeMail[ at ]Hotmail.com> wrote in message
news:%23KFZF02JGHA.3332[ at ]TK2MSFTNGP11.phx.gbl...
[Quoted Text]
> Well, I tried this but still got the same error. wdOpenFormatDocument has
> a value of 0.
> ActiveDocument.MailMerge.OpenDataSource
> ("C:\OpenDataSource\OpenDataSource.xls", wdOpenFormatDocument)
>
> I tried this and it worked.
> ActiveDocument.MailMerge.OpenDataSource _
> Name:="C:\OpenDataSource\OpenDataSource.xls", _
> Format:=wdOpenFormatAuto
>
> Is it actually the case that position-based parameters don't work in Word
> at all? The reason this is important is that I wanted to demonstrate that
> the following statement, which used to work in PowerBuilder for Word 9.0,
> and which no longer works in 11.0, DOES work in a non-PowerBuilder
> environment. So it's important that I be able to use positioning instead
> of naming.
>
> ole_word_file.MailMerge.OpenDataSource
> ("C:\OpenDataSource\OpenDataSource.xls",0,FALSE,TRUE,FALSE,FALSE,"","",FALSE,"","","Entire
> Spreadsheet")
>
>
> "Doug Robbins - Word MVP" <dkr[ at ]REMOVETHISmvps.org> wrote in message
> news:e6%23LQfpJGHA.2212[ at ]TK2MSFTNGP15.phx.gbl...
>> Probably each of the wdOpenFormat constants does have a unique numeric
>> value. As I do not know what they are and therefore cannot say whether 0
>> is a valid value, why not use the format that you want using its text
>> format. The following from the Visual Basic Help file gives the the
>> WdOpenFormat constants:
>>
>> Format Optional Variant. The file converter used to open the document.
>> Can be one of the WdOpenFormat constants. To specify an external file
>> format, use the OpenFormat property with the FileConverter object to
>> determine the value to use with this argument.
>>
>> WdOpenFormat can be one of these WdOpenFormat constants.
>> wdOpenFormatAllWord
>> wdOpenFormatAuto Default.
>> wdOpenFormatDocument
>> wdOpenFormatEncodedText
>> wdOpenFormatRTF
>> wdOpenFormatTemplate
>> wdOpenFormatText
>> wdOpenFormatUnicodeText
>> wdOpenFormatWebPages
>> wdOpenFormatXML
>>
>>
>> --
>> Hope this helps.
>>
>> Please reply to the newsgroup unless you wish to avail yourself of my
>> services on a paid consulting basis.
>>
>> Doug Robbins - Word MVP
>>
>> "Laurel" <FakeMail[ at ]Hotmail.com> wrote in message
>> news:Ore3RYoJGHA.344[ at ]TK2MSFTNGP11.phx.gbl...
>>> This is the only statement in a macro I've created. If I use only the
>>> first parameter (leave off the format parameter, 0), it works fine. If
>>> I add the zero, I get a syntax error. What am I doing wrong?
>>>
>>> ActiveDocument.MailMerge.OpenDataSource
>>> ("C:\OpenDataSource\OpenDataSource.xls",0)
>>>
>>>
>>>
>>
>>
>
>


Re: Syntax error calling MailMerge.OpenDataSource
"Laurel" <FakeMail[ at ]Hotmail.com> 08.02.2006 18:41:48
I got this answer from Peter Jamieson in another forum. I'm reposting it
here in case anyone else was looking at this and wondering about the answer.

Looking at your post in the "beginners" forum, one problem is that you're
using

Activedocument.Mailmerge.OpenDataSource (filename,0)

when VBA wants

Activedocument.Mailmerge.OpenDataSource filename,0

because you are making a method call, not a function call.

The reason

Activedocument.Mailmerge.OpenDataSource (filename)

works is because (filename) is a valid expression. (Actually I'm not an
expert on this stuff so don't take my word for it, but I think you will
discover that the following call works as well:

Activedocument.Mailmerge.OpenDataSource (filename),(0)

The call I made when testing was more like:


ActiveDocument.MailMerge.MainDocumentType = wdNotAMergeDocument
ActiveDocument.MailMerge.OpenDataSource _
"C:\mywb\Book1.xls", _
wdOpenFormatAuto, _
False, False, False, False, _
"", "", _
False, _
"", "", _
"Entire Spreadsheet", _
"", "", False, wdMergeSubTypeWord2000

"Laurel" <FakeMail[ at ]Hotmail.com> wrote in message
news:Ore3RYoJGHA.344[ at ]TK2MSFTNGP11.phx.gbl...
[Quoted Text]
> This is the only statement in a macro I've created. If I use only the
> first parameter (leave off the format parameter, 0), it works fine. If I
> add the zero, I get a syntax error. What am I doing wrong?
>
> ActiveDocument.MailMerge.OpenDataSource
> ("C:\OpenDataSource\OpenDataSource.xls",0)
>

>


Home | Search | Terms | Imprint | Contact
Newsgroups Reader - provided by WiredBox.Net