Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > Beginning VB 6
|
Beginning VB 6 For coders who are new to Visual Basic, working in VB version 6 (not .NET).
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning VB 6 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 23rd, 2007, 02:06 PM
Registered User
 
Join Date: Apr 2007
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Re-protecting a Word Form with VBScript

I have the following code which unprotects and updates a Word template. My problem is that I cannot figure out how to re-protect the form.

Code below:
<script language = "vbscript">
On Error Resume Next
 'attempt to get an existing running copy of Word
 Set objWord = GetObject(, "Word.Application")
 'if error occurred, then couldn't find Word, create new instance
If Err Then
   Err.Clear
   Set objWord = CreateObject("Word.Application")
End If
objWord.Visible = True
'open template as a new document
Set objDoc = objWord.Documents.Add("H:\Forms\ProtectedForm.dot" )
objDoc.Unprotect
Set objRange = objDoc.Bookmarks("EENumber").Range
objRange.Text = "123456"
Set objRange = objDoc.Bookmarks("EEName").Range
objRange.Text = "Lane, Lois"
'Re-protect document
'I've tried the following 2 methods without success
'objDoc.Protect Type:=wdAllowOnlyFormFields, NoReset:=True
'objDoc.Protect(wdAllowOnlyFormFields,True)
</script>


Any help would be appreciated.






Similar Threads
Thread Thread Starter Forum Replies Last Post
Form and bookmarks in Word paul20091968 Word VBA 0 May 16th, 2006 09:09 AM
creating a form in ms word kaly VB How-To 13 August 7th, 2005 09:25 PM
VBScript - Sql Server 2000 - MS Word delight_ravi VBScript 0 December 24th, 2004 03:52 AM
display word document in form collie VB.NET 2002/2003 Basics 1 September 12th, 2004 09:53 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.