Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 07-13-2015, 11:00 PM
macropod's Avatar
macropod macropod is offline Help with if then statements Windows 7 64bit Help with if then statements Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,467
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Inserting the new item is easy enough, but you also need to be able to delete it again if the user changes the dropdown selection. The following code should suffice. See attached demo.
Code:
Sub OptTxtFmFld()
Dim Prot As Variant, BmkRng As Range
Const Pwd As String = "" 'Insert password here
Const BmkNm As String = "BkMk" ' The bookmark name
With ActiveDocument
  Prot = .ProtectionType
  If .ProtectionType <> wdNoProtection Then
    Prot = .ProtectionType
    .Unprotect Password:=Pwd
  End If
  If .Bookmarks.Exists(BmkNm) Then
    Set BmkRng = .Bookmarks(BmkNm).Range
    If .FormFields("Dropdown1").Result = "1000" Then
      .FormFields.Add BmkRng, wdFieldFormTextInput
    Else
      BmkRng.Delete
    End If
    .Bookmarks.Add BmkNm, BmkRng
  Else
    MsgBox "Bookmark: " & BmkNm & " not found."
  End If
  .Protect Type:=Prot, Password:=Pwd, NoReset:=True
End With
Set BmkRng = Nothing
End Sub

Attached Files
File Type: docm FormFieldDemo.docm (30.5 KB, 23 views)
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #2  
Old 07-14-2015, 05:22 AM
brent chadwick brent chadwick is offline Help with if then statements Windows 8 Help with if then statements Office 2013
Advanced Beginner
Help with if then statements
 
Join Date: Mar 2015
Posts: 86
brent chadwick is on a distinguished road
Default

So what you are saying is that this code should be added to the exit macro of the drop-down menu?
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Help with if then statements Multiple If statements, Jamal NUMAN Excel 16 11-15-2022 11:59 PM
Countif statements Alaska1 Excel 5 02-05-2015 07:55 PM
Help with if then statements Using IF statements stuwoolf Excel 2 01-10-2015 01:58 PM
Help with if then statements count if statements Alaska1 Excel 1 05-14-2014 08:21 AM
IF statements that shifts to right. kent Excel 0 01-19-2006 02:23 PM

Other Forums: Access Forums

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