Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 03-06-2015, 08:06 PM
brent chadwick brent chadwick is offline Update fields and Tables of Content with one macro Windows 8 Update fields and Tables of Content with one macro Office 2013
Advanced Beginner
Update fields and Tables of Content with one macro
 
Join Date: Mar 2015
Posts: 86
brent chadwick is on a distinguished road
Default Update fields and Tables of Content with one macro

Hi guys, new to this forum and new to vba. I have a user form with a TOC and a field section that needs to be updated often. I wrote some VBA in Mac and it works fine, however when I transfer over to Windows the code does not work-I'm stumped here's the code-

Sub UpdateFields()
'
' UpdateFields Macro
'
'
If ActiveDocument.ProtectionType = wdNoProtection Then


ActiveDocument.Protect Type:=wdAllowOnlyFormFields, NoReset:=True
End If
If ActiveDocument.ProtectionType <> wdNoProtection Then
Selection.Range.Sections.First.Range.Select
Selection.Fields.Update
End If
With ActiveDocument
.Unprotect
ActiveDocument.TablesOfContents(1).Update
End With
With ActiveDocument
.Protect wdAllowOnlyFormFields, NoReset:=True
End With

End SubÏ

This runs great in Mac but does not work in Windows and gives me an error code of "The requested member of the collection does not exist". Thanks for your help-
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Forms fields: edit content easily in tables kirby gilman Word 8 12-04-2014 08:43 AM
Update fields and Tables of Content with one macro Macro to select and update all tables in document CircleG Word VBA 6 10-17-2014 07:25 PM
Auto Update Fields Macro kveldulv Outlook 0 06-07-2013 02:30 PM
Update fields and Tables of Content with one macro macro to update fields PeaceDove Word 3 01-17-2012 02:45 PM
Macro to update fields rhatx Word VBA 0 03-02-2011 12:14 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 09:23 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