OTWarrior
10-26-2009, 04:56 AM
We use late binding in Access to reference the other office apps, as different machines have different versions of office.
I am trying to create a function that will password protect an opened word document, but allow a bookmarked section to remain editable.
This is what I have so far:
Word version (macro):
Sub Macro1()
Selection.GoTo What:=wdGoToBookmark, name:="Section2"
Selection.Editors.Add wdEditorEveryone
ActiveDocument.Protect Password:="a", NoReset:=False, Type:= _
wdAllowOnlyReading, UseIRM:=False, EnforceStyleLock:=False
End Sub
Access version (part of a sub):
Dim sel As Object
Set sel = objOfficeApp.Selection
sel.GoTo What:=-1, name:="Section2"
sel.Editors.Add 3 ' wdEditorEveryone
objOfficeApp.ActiveDocument.Protect Password:="Password", NoReset:=False, _
Type:=3, UseIRM:=False, EnforceStyleLock:=False
objOfficeApp.ActiveDocument.Save
objOfficeApp.Visible = True
it always seems to fail on Set sel = objOfficeApp.Selection, specifically the selection part
How do I do selection on late binding?
I am trying to create a function that will password protect an opened word document, but allow a bookmarked section to remain editable.
This is what I have so far:
Word version (macro):
Sub Macro1()
Selection.GoTo What:=wdGoToBookmark, name:="Section2"
Selection.Editors.Add wdEditorEveryone
ActiveDocument.Protect Password:="a", NoReset:=False, Type:= _
wdAllowOnlyReading, UseIRM:=False, EnforceStyleLock:=False
End Sub
Access version (part of a sub):
Dim sel As Object
Set sel = objOfficeApp.Selection
sel.GoTo What:=-1, name:="Section2"
sel.Editors.Add 3 ' wdEditorEveryone
objOfficeApp.ActiveDocument.Protect Password:="Password", NoReset:=False, _
Type:=3, UseIRM:=False, EnforceStyleLock:=False
objOfficeApp.ActiveDocument.Save
objOfficeApp.Visible = True
it always seems to fail on Set sel = objOfficeApp.Selection, specifically the selection part
How do I do selection on late binding?