PDA

View Full Version : convert text to table



johanleeuk
05-14-2019, 06:36 AM
I want make a Macro to convert multiple choice to table like below please help me thank you so much
SOURCE
Question 1: When he lived in the city, he. to the theater twice a week.
A. was going
B. uses to go
C. has gone
D. used to go
Solution: Choose D
describe for question 1
Question 2: It's very hot today. I wish I. on the beach now.
A. had been
B. was
C. were
D. am
Solution: Choose C
describe for question 2
RESULT


Question
When he lived in the city, he. to the theater twice a week.


Choice A
was going


Choice B
uses to go


Choice C
has gone


Choice D
used to go


Correct
D


describe
describe for question 1





Question
It's very hot today. I wish I. on the beach now.


Choice A
was


Choice B
uses to go


Choice C
am


Choice D
were


Correct
C


describe
describe for question 2

gmaxey
05-14-2019, 07:33 AM
Johan,

This is not a free macro writing service. To get you started, you could try something like this:


Sub ScratchMacro()
'A basic Word macro coded by Greg Maxey
Dim oRng As Range
Dim oRngConvert As Range
Set oRng = ActiveDocument.Range
With oRng.Find
.Text = "Question [0-9]{1,}"
.MatchWildcards = True
While .Execute
oRng.MoveEnd wdParagraph, 7
Set oRngConvert = oRng.Duplicate
oRngConvert.ConvertToTable
oRngConvert.End = oRngConvert.Tables(1).Range.End
oRngConvert.Collapse wdCollapseEnd
oRngConvert.InsertBefore vbCr
oRng.Collapse wdCollapseEnd
Wend
End With
lbl_Exit:
Exit Sub
End Sub

johanleeuk
05-14-2019, 07:43 AM
Thank you so much i will try

Johan,

This is not a free macro writing service. To get you started, you could try something like this:


Sub ScratchMacro()
'A basic Word macro coded by Greg Maxey
Dim oRng As Range
Dim oRngConvert As Range
Set oRng = ActiveDocument.Range
With oRng.Find
.Text = "Question [0-9]{1,}"
.MatchWildcards = True
While .Execute
oRng.MoveEnd wdParagraph, 7
Set oRngConvert = oRng.Duplicate
oRngConvert.ConvertToTable
oRngConvert.End = oRngConvert.Tables(1).Range.End
oRngConvert.Collapse wdCollapseEnd
oRngConvert.InsertBefore vbCr
oRng.Collapse wdCollapseEnd
Wend
End With
lbl_Exit:
Exit Sub
End Sub

macropod
05-14-2019, 04:30 PM
Kindly read http://www.vbaexpress.com/forum/faq.php?faq=new_faq_item#faq_posthelp_faq_item. "please help me solve this problem" is not a meaningful thread title.