Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 10-05-2015, 06:01 PM
brent chadwick brent chadwick is offline Help with Case and Select case Windows 8 Help with Case and Select case Office 2013
Advanced Beginner
Help with Case and Select case
 
Join Date: Mar 2015
Posts: 86
brent chadwick is on a distinguished road
Default

As far as #2 I meant use text instead of the character-
Reply With Quote
  #2  
Old 10-05-2015, 06:52 PM
macropod's Avatar
macropod macropod is offline Help with Case and Select case Windows 7 64bit Help with Case and Select case 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

I used Chr(148) because experience has taught me the VBE tends to transform ” into ".
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 10-06-2015, 05:17 AM
brent chadwick brent chadwick is offline Help with Case and Select case Windows 8 Help with Case and Select case Office 2013
Advanced Beginner
Help with Case and Select case
 
Join Date: Mar 2015
Posts: 86
brent chadwick is on a distinguished road
Default

Got it. Now I understand that you just manually created a dropdown menu whereas I have to use code for the dropdown because I am inserting everything via macro. I thought you had some hidden code somewhere that I was unaware of. Thanks Paul, I have learned much from the master-
Reply With Quote
  #4  
Old 10-06-2015, 05:40 AM
macropod's Avatar
macropod macropod is offline Help with Case and Select case Windows 7 64bit Help with Case and Select case 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

If you need to add the dropdown programmatically, you could use a separate macro, coded along the lines of:
Code:
Sub CreateDropDown()
Application.ScreenUpdating = False
Dim Prot As Variant, Rng As Range, FmFld As FormField
Const Pwd As String = ""
With ActiveDocument
  Prot = .ProtectionType
  If .ProtectionType <> wdNoProtection Then
    Prot = .ProtectionType
    .Unprotect Password:=Pwd
  End If
  Set Rng = ???
  Rng.InsertBefore Chr(147)
  Rng.Collapse wdCollapseEnd
  Set FmFld = .FormFields.Add(Range:=Rng, Type:=wdFieldFormDropDown)
   With FmFld
    .Name = "RecordsDD"
    .EntryMacro = ""
    .ExitMacro = "ConditionalContent"
    .Enabled = True
    With .DropDown.ListEntries
      .Add Name:="Record Collection"
      .Add Name:="U.S. Public Records Index"
      .Add Name:="United States Public Records 1970-2010"
    End With
  End With
  .Protect Type:=Prot, Password:=Pwd, NoReset:=True
End With
Set FmFld = Nothing: Set Rng = Nothing
Application.ScreenUpdating = True
End Sub
As you'll see, I've basically left the insertion range undefined; you'll have to replace the ??? with an appropriate definition.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #5  
Old 10-06-2015, 12:13 PM
brent chadwick brent chadwick is offline Help with Case and Select case Windows 8 Help with Case and Select case Office 2013
Advanced Beginner
Help with Case and Select case
 
Join Date: Mar 2015
Posts: 86
brent chadwick is on a distinguished road
Default

Thanks Paul, good talking to you-
Reply With Quote
  #6  
Old 10-14-2015, 03:53 AM
brent chadwick brent chadwick is offline Help with Case and Select case Windows 8 Help with Case and Select case Office 2013
Advanced Beginner
Help with Case and Select case
 
Join Date: Mar 2015
Posts: 86
brent chadwick is on a distinguished road
Default

For Setting Range I used
Code:
Set Rng = Selection.Range
and it gives me a "Run time error 4120." What am I doing wrong?
Reply With Quote
  #7  
Old 10-14-2015, 04:12 AM
brent chadwick brent chadwick is offline Help with Case and Select case Windows 8 Help with Case and Select case Office 2013
Advanced Beginner
Help with Case and Select case
 
Join Date: Mar 2015
Posts: 86
brent chadwick is on a distinguished road
Default

So I messed with a little bit and I fixed it but have no idea how, here's the code that works:

Code:
Option Explicit
Const BmkCCBmk As String = "CCBookmark" 'bookmark name
Const Pwd As String = "" 'Filling in Forms password

Sub PublicRecordsCombinedMacro()
'PublicRecordsCombinedMacro Macro
Application.ScreenUpdating = False
Dim Prot As Variant, Rng As Range, FmFld As FormField
With ActiveDocument
  Prot = .ProtectionType
  If .ProtectionType <> wdNoProtection Then
    Prot = .ProtectionType
    .Unprotect
   End If
Set Rng = Selection.Range
With ActiveDocument
  Rng.Collapse wdCollapseStart
  'Dropdown Menu for Record Collection
  Set FmFld = .FormFields.Add(Range:=Rng, Type:=wdFieldFormDropDown)
  With FmFld
    .Name = "RecordsDD"
    .EntryMacro = ""
    .ExitMacro = "CondtionalContent"
    .Enabled = True
    With .DropDown.ListEntries
      .Add Name:="Record Collection"
      .Add Name:="U.S. Public Records Index"
      .Add Name:="United States Public Records 1970-2010"
    End With
  End With
  With Rng
    .End = FmFld.Range.End
    .InsertBefore Chr(210)
    .InsertAfter ","
    .Collapse wdCollapseEnd
  End With
  With Rng
    .End = FmFld.Range.End
    .Collapse wdCollapseEnd
  End With
  .Protect Type:=wdAllowOnlyFormFields, NoReset:=True, Password:=Pwd
  End With
  Set FmFld = Nothing: Set Rng = Nothing
Application.ScreenUpdating = True
End With
End Sub
Sign me stumped-
Reply With Quote
  #8  
Old 10-14-2015, 04:28 AM
macropod's Avatar
macropod macropod is offline Help with Case and Select case Windows 7 64bit Help with Case and Select case 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

Quote:
Originally Posted by brent chadwick View Post
So I messed with a little bit
No kidding!
Code:
Const BmkCCBmk As String = "CCBookmark" 'bookmark name
Const Pwd As String = "" 'Filling in Forms password
 
Sub PublicRecordsCombinedMacro()
'PublicRecordsCombinedMacro Macro
Application.ScreenUpdating = False
Dim Prot As Variant, Rng As Range, FmFld As FormField
With ActiveDocument
  Prot = .ProtectionType
  If .ProtectionType <> wdNoProtection Then
    Prot = .ProtectionType
    .Unprotect
   End If
  Set Rng = Selection.Range
  Rng.Collapse wdCollapseStart
  'Dropdown Menu for Record Collection
  Set FmFld = .FormFields.Add(Range:=Rng, Type:=wdFieldFormDropDown)
  With FmFld
    .Name = "RecordsDD"
    .EntryMacro = ""
    .ExitMacro = "CondtionalContent"
    .Enabled = True
    With .DropDown.ListEntries
      .Add Name:="Record Collection"
      .Add Name:="U.S. Public Records Index"
      .Add Name:="United States Public Records 1970-2010"
    End With
  End With
  With Rng
    .End = FmFld.Range.End
    .InsertBefore Chr(210)
    .InsertAfter ","
    .Collapse wdCollapseEnd
  End With
  With Rng
    .End = FmFld.Range.End
    .Collapse wdCollapseEnd
  End With
  .Protect Type:=wdAllowOnlyFormFields, NoReset:=True, Password:=Pwd
End With
Set FmFld = Nothing: Set Rng = Nothing
Application.ScreenUpdating = True
End Sub
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #9  
Old 10-14-2015, 04:01 AM
macropod's Avatar
macropod macropod is offline Help with Case and Select case Windows 7 64bit Help with Case and Select case 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

Does the document you're trying to add the formfield to contain the ConditionalContent macro?
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #10  
Old 10-14-2015, 04:03 AM
brent chadwick brent chadwick is offline Help with Case and Select case Windows 8 Help with Case and Select case Office 2013
Advanced Beginner
Help with Case and Select case
 
Join Date: Mar 2015
Posts: 86
brent chadwick is on a distinguished road
Default

Yes it is-
Reply With Quote
  #11  
Old 10-14-2015, 04:11 AM
macropod's Avatar
macropod macropod is offline Help with Case and Select case Windows 7 64bit Help with Case and Select case 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

Well, I'm not getting any errors with the code as provided, when using:
Set Rng = Selection.Range
and the ConditionalContent macro is present.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #12  
Old 10-14-2015, 05:53 AM
macropod's Avatar
macropod macropod is offline Help with Case and Select case Windows 7 64bit Help with Case and Select case 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

For each formfield you want to trigger the unlinking with, add the line:
FmFld.ExitMacro = "Unlink"
after the last existing line referencing that formfield. Supplement that with the following macro:
Code:
Sub Unlink()
With ActiveDocument
  If .ProtectionType <> wdNoProtection Then
    .Unprotect Password:=Pwd
  End If
  .Fields.Unlink
End With
End Sub
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #13  
Old 10-15-2015, 09:21 AM
brent chadwick brent chadwick is offline Help with Case and Select case Windows 8 Help with Case and Select case Office 2013
Advanced Beginner
Help with Case and Select case
 
Join Date: Mar 2015
Posts: 86
brent chadwick is on a distinguished road
Default

Thanks Paul, I have learned much from the master-again-
Reply With Quote
  #14  
Old 10-18-2015, 04:40 AM
brent chadwick brent chadwick is offline Help with Case and Select case Windows 8 Help with Case and Select case Office 2013
Advanced Beginner
Help with Case and Select case
 
Join Date: Mar 2015
Posts: 86
brent chadwick is on a distinguished road
Default

Quick question, is it possible to have Italic and regular font in a dropdown menu? Thanks-
Reply With Quote
  #15  
Old 10-18-2015, 12:52 PM
macropod's Avatar
macropod macropod is offline Help with Case and Select case Windows 7 64bit Help with Case and Select case 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

Quick answer: No.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Replace & case Jennifer Murphy Word 1 02-11-2013 03:26 AM
Question about Case statement Jennifer Murphy Word VBA 1 01-05-2013 02:30 PM
Case Sensitive (contains) Selection apolloman Excel 2 07-12-2011 04:50 AM
Help with Case and Select case From all UPPER CASE to Proper Case davers Word 1 04-30-2009 12:41 PM
Upper to lower case jd Excel 1 04-28-2006 07:40 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 06:51 PM.


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