We have an add-in that lists names of bookmarks that the user selects and it pastes the bookmark into the current document. this has been working fine on a windows 7 pc running word 2010. when we run it on a windows 10 pc with word 2010 we get a runtime error '91' object variable or with block variable not set. Any help with will be appreciated as it was written by an ex employee and I have very little VBA experience.
Code:
Sub STC161()
setvariables
AppCond "STC161", STcond
End Sub
Sub STC162()
setvariables
AppCond "STC162", STcond
End Sub
Sub AppCond(varbkmrk, doclocation)
'
' AppCond Macro
'
Documents.Open filename:=doclocation, _
ConfirmConversions:=False, ReadOnly:=False, AddToRecentFiles:=False, _
PasswordDocument:="", PasswordTemplate:="", Revert:=False, _
WritePasswordDocument:="", WritePasswordTemplate:="", Format:= _
wdOpenFormatAuto
Selection.GoTo What:=wdGoToBookmark, Name:=varbkmrk
Selection.Find.ClearFormatting
With Selection.Find
.Text = ""
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Copy
ActiveWindow.Close
Selection.EndKey Unit:=wdStory
Selection.Paste
Selection.fields.Update
Selection.EndKey Unit:=wdStory
End Sub
Sub setvariables()
STcond = "c:\Template\book marks\book marks conditions.doc"
End Sub