![]() |
|
#3
|
|||
|
|||
|
My boss wants it this way, though, so that's what I'm exploring!
I have a protected word doc with form fields. Some of the pages will only be necessary under certain conditions, and I would like to make a button which removes unneeded pages depending on the need. I am BRAND new to VBA and have found this code online: Sub Clearpages() Dim rgePages As Range Dim PageCount As Integer PageCount = ActiveDocument.ComputeStatistics(wdStatisticPages) Selection.GoTo What:=wdGoToPage, Which:=wdGoToAbsolute, Count:=2 Set rgePages = Selection.Range Selection.GoTo What:=wdGoToPage, Which:=wdGoToAbsolute, Count:=PageCount rgePages.End = Selection.Bookmarks("\Page").Range.End rgePages.Delete End Sub This works until I protect the doc, then stops working. I read on another page that I need to insert the code "Sheetname.Unprotect Password:="password"/"Sheetname.Protect Password:="password"" at the beginning and end of this code, but I can't make that work either. What am I doing WRONG???? Best, Seth |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
How to populate dependent dropdowns and auto-fill text fields simultaneously?
|
vera | Word VBA | 1 | 10-07-2016 07:41 PM |
| Fill MS-Word docs/forms with name address data from external source | yajnaval | Word | 2 | 02-14-2015 10:48 PM |
| Problem with customizing outlook 2013 contact form | aroshlakshan | Outlook | 0 | 02-17-2013 02:58 AM |
Help with fill in form
|
RetiredFD | Word | 1 | 03-18-2012 12:52 AM |
Customizing the default contact form in Outlook 2010
|
Jackissimus | Outlook | 5 | 03-24-2011 02:33 PM |