automation and security

N

nebbiasun

I have a split database which calls a word document (mail merge from
query) which works perfectly in both access 2003 and 2007. I have
secured the frontend and backend (user level security) in 2003 also
without problems. I have tried to migrate the same files to an access
2007 without success. I receive error messages that I don't have
permission to access the frontend or OBDC login failures.

I've played with this quite a bit and can not find a solution. Is this
a bug in 2007 or am I missing a reference or something else entirely
This is the code I've been using;

Private Sub cmdMerge_Click()
Dim wrdApp As Object
Dim wrdDoc As Object
Dim blnStartWord As Boolean
Dim strSQL As String

On Error Resume Next

Set wrdApp = GetObject(, "Word.Application")
If wrdApp Is Nothing Then
Set wrdApp = CreateObject("Word.Application")
If wrdApp Is Nothing Then
MsgBox "Can't start Word.", vbExclamation
Exit Sub
Else
blnStartWord = True
End If
End If

On Error GoTo ErrHandler

strSQL = "SELECT * FROM qryNew"

Set wrdDoc = wrdApp.Documents.open("c:\Templates & Forms\Letters
\New.doc")
With wrdDoc.MailMerge
..OpenDataSource _
Name:="", _
LinkToSource:=True, _
Connection:="DSN=MS Access Database;DBQ=" & CurrentDb.Name, _
SQLStatement:=strSQL, _
SubType:=8 ' = wdMergeSubTypeWord2000
..SuppressBlankLines = True
End With

wrdApp.Visible = True
wrdApp.Activate

ExitHandler:
Set wrdDoc = Nothing
Set wrdApp = Nothing
Exit Sub

ErrHandler:
MsgBox Err.Description, vbExclamation
If Not wrdDoc Is Nothing Then
wrdDoc.close SaveChanges:=False
End If
If Not wrdApp Is Nothing And blnStartWord Then
wrdApp.Quit SaveChanges:=Nothing
End If
Resume ExitHandler
End Sub
 
A

Arvin Meyer [MVP]

You don't say which OS you are using. While a missing reference is possible,
it is also likely that this may be a Vista, permissions issue. If you are
using Vista, try running as Administrator or turning off UAC and see if that
solves your problem.
 

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