Link to home
Start Free TrialLog in
Avatar of timb551
timb551Flag for United Kingdom of Great Britain and Northern Ireland

asked on

Access and Word 2013 upgrade issue

Hi

We are going through a process of updating our desktops to Office 2013 from 2010.

We have a set of documents located on a network drive running on a Server 2008

Within an Access DB there is a word control function (below) which opens up word documents

In Word 2010 it works fine but it doesnt work in 2013.

Function Private Sub General_Letter_02_Click() is called from a form populated with data that is required to merge to a read only copy of a word letter.

The error we receive using Word 2013 is -

“You are not allowed to edit this selection because it is protected.”

The code fail on line 8 of Public Sub WordReplace(FieldName As String, DataValue As Variant)

Private Sub General_Letter_02_Click()
1.      WordOpen "xm-General Letter 02.docx"
2.      WordReplace "<Client_File.Title>", Forms![Client File]![TITLE]
3.      WordReplace "<Client_File.First>", Forms![Client File]![first]
4.      WordReplace "<Client_File.Last>", Forms![Client File]![LAST]
5.      WordReplace "<Client_File.Company>", Forms![Client File]![Company]
6.      WordReplace "<Client_File.Address1>", Forms![Client File]![Address1]
7.      WordReplace "<Client_File.Address2>", Forms![Client File]![ADDRESS2]
8.      WordReplace "<Client_File.PostTown>", Forms![Client File]![PostTown]
9.      WordReplace "<Client_File.County>", Forms![Client File]![COUNTY]
10.      WordReplace "<Client_File.PostCode>", Forms![Client File]![PostCode]
11.      WordReplace "<Client_File.Title>", Forms![Client File]![TITLE]
12.      WordReplace "<Client_File.Last>", Forms![Client File]![LAST]
13.      WordReplace "<Client_File.ClientRef>", Forms![Client File]![ClientRef]
14.      WordReplace "<user_security.first_name>", GetCurrentUserFirstName()
15.      WordReplace "<user_security.last_name>", GetCurrentUserLastName()
16.      WordReplace "<user_security.Department>", GetCurrentDepartment()
17.      WordSaveAsTemporary
18.      WordShow
End Sub


Public Sub WordOpen(FileName As String)
1.      Set Word = CreateObject("Word.Application")
2.      Word.Documents.Open ("L:\word\datasafe letters\worddocs\" & FileName)
End Sub


Public Sub WordReplace(FieldName As String, DataValue As Variant)
1.      Dim myRange As Object
2.      If (IsNull(DataValue)) Then
3.      DataValue = ""
4.      End If

5.      Set myRange = Word.ActiveDocument.Content

6.      myRange.Find.Execute FindText:=FieldName, Forward:=True ', MatchCase:=False
7.      While (myRange.Find.Found = True)
8.      myRange.Text = DataValue

9.      Set myRange = Word.ActiveDocument.Content
10.      myRange.Find.Execute FindText:=FieldName, Forward:=True ', MatchCase:=False
11.      Wend
End Sub


thanks
Avatar of ste5an
ste5an
Flag of Germany image

Is this code a Word macro or code run from Access?

btw, use always Option Explicit..
As a test only, see if lowering your UAC to its lowest setting helps.
Avatar of timb551

ASKER

VB code within Access.

I will try the UAC tomorrow, thanks
Avatar of timb551

ASKER

changing UAC didnt make a difference.
ASKER CERTIFIED SOLUTION
Avatar of timb551
timb551
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of timb551

ASKER

Issue not resolved but no help here.