Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 07-18-2014, 05:24 AM
gmaxey gmaxey is offline VBA Batch Find & Replace for all MSOffice extensions, to replace File Name and Content of the File Windows 7 32bit VBA Batch Find & Replace for all MSOffice extensions, to replace File Name and Content of the File Office 2010 (Version 14.0)
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,635
gmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nice
Default


The forum is full of examples of batch processing files. For the dropdown piece, it would probably be easier to just clear the existing list and fill it with a new list. The following code assumes a content control named "Job Title" and a formfield bookmarked "JobTitle" the contents of each are cleared and filled with a new list.

Just pass your document to process to the macro.

HTML Code:
Sub RefillDD(oDoc As Word.Document)
'A basic Word macro coded by Greg Maxey
Dim arrLEs() As String
Dim lngIndex As Long
Dim lngPT As Long
Dim bProt As Boolean
  lngPT = oDoc.ProtectionType
  If lngPT <> wdNoProtection Then
    bProt = True
    oDoc.Unprotect
  End If
  On Error Resume Next
  arrLEs = Split("X,Y,Z", ",")
  With oDoc.SelectContentControlsByTitle("Job Title").Item(1)
    For lngIndex = .DropdownListEntries.Count To 1 Step -1
      .DropdownListEntries(lngIndex).Delete
    Next lngIndex
    For lngIndex = 0 To UBound(arrLEs)
      .DropdownListEntries.Add arrLEs(lngIndex), arrLEs(lngIndex)
    Next lngIndex
  End With
  With oDoc.FormFields("JobTitle")
    .DropDown.ListEntries.Clear
    For lngIndex = 0 To UBound(arrLEs)
      .DropDown.ListEntries.Add arrLEs(lngIndex)
    Next lngIndex
  End With
  If bProt = True Then
    Select Case lngPT
     Case 2
       oDoc.Protect 2, True
     Case Else
       oDoc.Protect lngPT
    End Select
  End If
End Sub
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
  #2  
Old 09-11-2014, 03:41 AM
QA_Compliance_Advisor QA_Compliance_Advisor is offline VBA Batch Find &amp; Replace for all MSOffice extensions, to replace File Name and Content of the File Windows 7 32bit VBA Batch Find &amp; Replace for all MSOffice extensions, to replace File Name and Content of the File Office 2010 32bit
Advanced Beginner
VBA Batch Find &amp; Replace for all MSOffice extensions, to replace File Name and Content of the File
 
Join Date: Jul 2014
Posts: 44
QA_Compliance_Advisor is on a distinguished road
Default Replace entry list in dropdown

Quote:
Originally Posted by gmaxey View Post
The forum is full of examples of batch processing files. For the dropdown piece, it would probably be easier to just clear the existing list and fill it with a new list. The following code assumes a content control named "Job Title" and a formfield bookmarked "JobTitle" the contents of each are cleared and filled with a new list.

Just pass your document to process to the macro.

HTML Code:
Sub RefillDD(oDoc As Word.Document)
...
 End Sub
tried this code however, i am getting a 'runtime error 424' and highlighting
lngPT = oDoc.ProtectionType.

can anyone assist.
Reply With Quote
Reply

Tags
drop down lists, find & replace, vba, vba find and replace, vba script



Similar Threads
Thread Thread Starter Forum Replies Last Post
Search and replace/insert HTML code into Master File using tags dave8555 Excel 2 02-23-2014 03:51 PM
VBA Batch Find &amp; Replace for all MSOffice extensions, to replace File Name and Content of the File How to replace this word file using wildcard zhangzujin361 Word 1 01-18-2014 08:02 PM
VBA Batch Find &amp; Replace for all MSOffice extensions, to replace File Name and Content of the File Bad view when using Find and Find & Replace - Word places found string on top line paulkaye Word 4 12-06-2011 11:05 PM
VBA Batch Find &amp; Replace for all MSOffice extensions, to replace File Name and Content of the File Help with find and replace or query and replace shabbaranks Excel 4 03-19-2011 08:38 AM
MS word taking over file extensions jakes Word 0 10-22-2010 01:35 AM

Other Forums: Access Forums

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