Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #3  
Old 09-01-2017, 08:14 AM
strodden strodden is offline Customizing form fill docs with dropdowns Windows 10 Customizing form fill docs with dropdowns Office 2010 32bit
Novice
Customizing form fill docs with dropdowns
 
Join Date: Aug 2017
Posts: 22
strodden is on a distinguished road
Default Deleting Pages with macro on protected sheet

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
Reply With Quote
 

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Customizing form fill docs with dropdowns 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
Customizing form fill docs with dropdowns Help with fill in form RetiredFD Word 1 03-18-2012 12:52 AM
Customizing form fill docs with dropdowns Customizing the default contact form in Outlook 2010 Jackissimus Outlook 5 03-24-2011 02:33 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 06:50 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft