MailMerge Datasource not appearing in VBA when using DDE

G

garethjwelsh

Hi,
i am attempting to do a mailmerge. The main file that i am using has got a
data source setup correctly, when i open the file it correctly has a dialogue
box stating that this file needs to run a select statement and it is
selecting it from the correct source.

The problem is when i use the same file in a system when the correct file is
opened it doesn't have a datasource assigned to it. It is exactly the same
file as i have checked this already, but for some reason the datasource is
not accesible in VBA. I have used dde for communication in the system.

I was just wondering if anyone had any idea why the data source does not
appear attached to the Word 2003 file in VBA, i thought i might have opened
it in a strange way. Interestingly exactly the same code works perfectly on
someone elses computer so there must be some difference between my version of
word/windows or soemthing that causes the file to behave in this way.

Any help greatly appreciated.
 
P

Peter Jamieson

Word's behaviour in this area is significantly affected by a registry
setting - see

http://support.microsoft.com/kb/825765/en-us

for some further info. In particular, attempts to connect using code will
probably fail if you do not set this registry entry.

If following that article does not fix things for you, could you try to
clarify what you meant here:
but for some reason the datasource is
not accesible in VBA. I have used dde for communication in the system.

Peter Jamieson
 
G

garethjwelsh

Fantastic!! Thanks for your help Peter, it is greatly appreciated!!!

That works as a workaround, perhaps my talk of using DDE was a red herring,
i assumed it had something to do with the communication, but apparently it
was just XP security settings.

Does anyone know exactly why XP behaves in this way? or if any other
security settings affect this behaviour. It is just as i previously stated
someone who has the same setup on his PC, same version of XP and Word etc was
able to print using MailMerge correctly without the need to setup this
registry key. I was just curious if other people found any XP settings
affected the behaviour of word in mailMerge.

The possible security hole that this leaves might not be an acceptable
solution for our clients, so i was hoping there might another way of fixing
it, i know it can work on Windows XP, i just don't know how!!!
 
P

Peter Jamieson

Does anyone know exactly why XP behaves in this way?

The article I mentioned gives some indication of the type of problem the
registry fix is designed to prevent - when Word opens a data source, it is
executing non-Word code and potentially non-Microsoft code, any of which
might have nasty side effects. When Word opens a data source, it can
a. execute its own DDE code to go and get data from Excel or Access. In
that case, Excel/Access code and macros may execute, and Access queries can
also invoke Access VBA functions which can do pretty much anything.
b. execute ODBC driver code, OLEDB provider code, or text converter code,
any of which could be provided by a third party. For example, I wrote a
"text converter" a while ago that can invoke user-authored Word VBA code.
or if any other
security settings affect this behaviour. It is just as i previously stated
someone who has the same setup on his PC, same version of XP and Word etc
was
able to print using MailMerge correctly without the need to setup this
registry key.

That's interesting, but unfortunately I have no idea what else might
influence this particular "security feature" if your user has /exactly/ the
same version of Word (some earlier releases of Word XP worked differently).
I suppose if I was going to have a closer look, I'd start by looking at
a. whether Word macro security settings had any impact
b. whether the security settings related to the document, its template, the
data source, associated code had any impact, e.g. what if the Mail Merge
Main document is read-only, what if the data source is/is not located in a
trusted Internet zone, etc. etc.

I don't see why either of those things would make any logical difference to
what Word /should/ do, but there you go.

Peter Jamieson
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top