-
Problems EXCEL to Word
hi,
I have to update a few fields in a Word fill-in Form with values from an Excel spreadsheet.
To do this i need to unprotect the Word fill-in document, update the bookmarks in the Word document, re-protect the Word fill-in document,save it and completely close-down the Word-application.
So in my code below everything goes fine until i will re-protect the Word-document. It does nothing in Word 2003 under Windows XP.
Can you help me to find a solution ?
Here goes my coding:
[VBA]Public Sub EXcelWord()
Dim flag As String * 1
Dim WdObj As Object
Dim WdDoc As Object
Set WdObj = CreateObject("Word.Application")
WdObj.Visible = True
wdmodelclfullname = "C:\Data\word\checklist.dot"
WdObj.Documents.Open wdmodelclfullname
WdObj.ActiveDocument.Unprotect
WdObj.ActiveDocument.Bookmarks("text3").Range.Text = "This is my text3"
WdObj.ActiveDocument.Bookmarks("text4").Range.Text = "This is my text4"
If flag = "Y" Then _
WdObj.ActiveDocument.formfields("Check10").CheckBox.Value = True
WdObj.ActiveDocument.formfields("dropdown1").result = ActiveWorkbook.Worksheets(1).Range("C2").Value
WdObj.ActiveDocument.Protect Password:="", NoReset:=False, Type:= _
wdAllowOnlyFormFields
Set WdObj = Nothing
End Sub[/VBA]
THanks for any help .
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules