Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 05-04-2014, 06:35 AM
deboer deboer is offline Delete Unchecked Multiple Choice Answers Windows XP Delete Unchecked Multiple Choice Answers Office 2010 64bit
Novice
Delete Unchecked Multiple Choice Answers
 
Join Date: May 2014
Posts: 14
deboer is on a distinguished road
Default Delete Unchecked Multiple Choice Answers

Hi Macropod,
I look for the macro in https://www.msofficeforums.com/word-...le-choice.html that you created and maybe could be helpful for a similar situation.

How can I create a macro that will delete the unneeded answers to a multiple choice question?

The questions are in plain text, with "A", "B", "C", "D", & "E".

But the "right" answer instead of being BOLDed and UNDERLINEd is selected by checkbox Content Control.

Example:
Test Question


answer A
X answer B
answer C
answer D
answer E

It is possible the macro run with the document protected?



Thks
Reply With Quote
  #2  
Old 05-04-2014, 03:19 PM
macropod's Avatar
macropod macropod is offline Delete Unchecked Multiple Choice Answers Windows 7 32bit Delete Unchecked Multiple Choice Answers Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
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

As you can see from the preceding discussion, the solution depends on being able to identify what the possible answers are and, of those, which is the 'correct' answer. Without knowing more about the structure of your document, I can't say how amenable it might be to this kind of processing. Can you attach a document to a post with some representative data (delete anything sensitive)? You do this via the paperclip symbol on the 'Go Advanced' tab at the bottom of this screen.

PS: Please don't send PMs seeking help.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 05-05-2014, 12:47 AM
deboer deboer is offline Delete Unchecked Multiple Choice Answers Windows XP Delete Unchecked Multiple Choice Answers Office 2010 64bit
Novice
Delete Unchecked Multiple Choice Answers
 
Join Date: May 2014
Posts: 14
deboer is on a distinguished road
Default Macro Needed to Delete Unneeded Answers in Multiple Choice Format Question

Hi Paul,

As requested i attach a sample document for your analysis.
Basically what i want is to delete the rows of the answers not checkbox selected (anwser A, B and C).
If it is possible the macro run with the document protected it woul be better.

Thks
Attached Files
File Type: docx Sample.docx (13.5 KB, 43 views)
Reply With Quote
  #4  
Old 05-05-2014, 03:40 AM
macropod's Avatar
macropod macropod is offline Delete Unchecked Multiple Choice Answers Windows 7 32bit Delete Unchecked Multiple Choice Answers Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
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 a protected document using checkbox content controls as depicted in your sample, you would need code like:
Code:
Sub Demo()
Application.ScreenUpdating = False
Dim CCtrl As ContentControl, i As Long
Dim Pwd As String, pState As Variant
With ActiveDocument
  If .ProtectionType <> wdNoProtection Then
    Pwd = InputBox("Please enter the Password", "Password")
    pState = .ProtectionType
    .Unprotect Pwd
  End If
  With .Range
    For i = .ContentControls.Count To 1 Step -1
      With .ContentControls(i)
        If .Type = wdContentControlCheckBox Then
          If .Checked = False Then
            With .Range.Rows(1)
              .Range.Delete
              .Delete
            End With
          End If
        End If
      End With
    Next
  End With
  If pState <> wdNoProtection Then .Protect Type:=pState, NoReset:=True, Password:=Pwd
End With
Application.ScreenUpdating = True
End Sub
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #5  
Old 05-06-2014, 09:54 AM
deboer deboer is offline Delete Unchecked Multiple Choice Answers Windows XP Delete Unchecked Multiple Choice Answers Office 2010 64bit
Novice
Delete Unchecked Multiple Choice Answers
 
Join Date: May 2014
Posts: 14
deboer is on a distinguished road
Default

Amazing Paul!
Thank you so much, you're fantastic! That's exactly what I want.
You solved me a big problem.
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro Needed to Delete Unneeded Answers in Multiple Choice Format Question frustrated teacher Word VBA 6 05-02-2014 03:37 AM
Delete Unchecked Multiple Choice Answers multiple choice question ENEMALI Word VBA 1 09-29-2013 09:05 PM
Delete Unchecked Multiple Choice Answers Creating a multiple choice test McDoug Office 2 10-19-2012 10:02 AM
Delete Unchecked Multiple Choice Answers Linking multiple choice questions to answers Microsoftenquirer1000 Word 2 08-12-2012 02:49 PM
Linking multiple choice questions to answers Microsoftenquirer1000 Word 1 06-11-2012 06:53 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 08:23 PM.


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