Access Source

L

LDanix

I am using an Access table as my source for a mail merge. The database has a
password on it. Is there a way to use VBA to have it automatically enter the
password when it is opened?
I have a form in Access that contains a button that executes the open and
mailmerge commands on the Word document file.
 
L

LMiller

Sounds like we may be working on something similar. I'm stuck too. I'm
working on a "form filler" with Access as the source that will print multiple
documents when complete. How did you create the control buttons to print from
Access? Can you print 2 at a time? How about reprinting specific documents
if necessary instead of all of them. If you have any insight to the problem,
I sure would appreciate a response. Thanks
 
C

Cindy M.

Hi =?Utf-8?B?TERhbml4?=,
I am using an Access table as my source for a mail merge. The database has a
password on it. Is there a way to use VBA to have it automatically enter the
password when it is opened?
I think this can be done using an ODBC connection and supplying the password
with the PWD parameter.

If you don't know how to explicitly select a connection method, you need to
tell us the version of Office you're working with.

Then try recording connecting to the Access database in a macro. If you need
further help, after this point, we need to see the OpenDataSource the macro
recorder created.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or reply
in the newsgroup and not by e-mail :)
 
L

LDanix

Cindy M. said:
Hi =?Utf-8?B?TERhbml4?=,

I think this can be done using an ODBC connection and supplying the password
with the PWD parameter.

If you don't know how to explicitly select a connection method, you need to
tell us the version of Office you're working with.

Then try recording connecting to the Access database in a macro. If you need
further help, after this point, we need to see the OpenDataSource the macro
recorder created.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)


This reply is posted in the Newsgroup; please post any follow question or reply
in the newsgroup and not by e-mail :)
Here is the code that is currently in the Word document VBA:

Private Sub Document_Open()
Me.MailMerge.OpenDataSource
"\\calumet\apps\asset_tracking_system\Current Employee.odc"
Me.MailMerge.ViewMailMergeFieldCodes = False
Me.MailMerge.Destination = wdSendToNewDocument
Me.MailMerge.Execute
Me.Close
End Sub

Where do I add code to enter the password?
 
C

Cindy M.

Hi =?Utf-8?B?TERhbml4?=,
Here is the code that is currently in the Word document VBA:

Private Sub Document_Open()
Me.MailMerge.OpenDataSource
"\\calumet\apps\asset_tracking_system\Current Employee.odc"
Me.MailMerge.ViewMailMergeFieldCodes = False
Me.MailMerge.Destination = wdSendToNewDocument
Me.MailMerge.Execute
Me.Close
End Sub

Where do I add code to enter the password?
You don't. Please re-read my original message and answer the questions I asked.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or reply in
the newsgroup and not by e-mail :)
 
L

LDanix

Sorry, I thought the PWD parameter was something that could be added to that
code.
I am using Office 2003. Do I start recording the macro in Word?
 
C

Cindy M.

Hi =?Utf-8?B?TERhbml4?=,
Sorry, I thought the PWD parameter was something that could be added to that
code.
OLE DB is fussy; ODBC is more predictable. The code you showed me wants, in
adddition, to use an secondary *.odc file. These are not well documented and
it's difficult to get them to do what you think they ought to.
I am using Office 2003. Do I start recording the macro in Word?
Yes :)

In order to control the connection method in Word 2003, activate "Confirm
conversions on open" in Tools/Options/General. This will show you a list once
you've selected the file containing the data.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or reply
in the newsgroup and not by e-mail :)
 
L

LDanix

Cindy M. said:
Hi =?Utf-8?B?TERhbml4?=,

OLE DB is fussy; ODBC is more predictable. The code you showed me wants, in
adddition, to use an secondary *.odc file. These are not well documented and
it's difficult to get them to do what you think they ought to.

Yes :)

In order to control the connection method in Word 2003, activate "Confirm
conversions on open" in Tools/Options/General. This will show you a list once
you've selected the file containing the data.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)


This reply is posted in the Newsgroup; please post any follow question or reply
in the newsgroup and not by e-mail :)
I opened the database as ODBC. After saving the document, I reopened the
database and tried executing the command from the form with the button. Same
thing. Am I getting ahead of you? What do I do after selecting ODBC when I
open the database as the source file?
 
C

Cindy M.

Hi =?Utf-8?B?TERhbml4?=,
I opened the database as ODBC. After saving the document, I reopened the
database and tried executing the command from the form with the button. Same
thing. Am I getting ahead of you? What do I do after selecting ODBC when I
open the database as the source file?
In my original response I said:
Then try recording connecting to the Access database in a macro. If you need
further help, after this point, we need to see the OpenDataSource the macro
recorder created.
The point is to get the connection information Word requires for an ODBC
connection, which will include a PWD (password) parameter. Then use this in
your code, rather than what you already have.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or reply
in the newsgroup and not by e-mail :)
 

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