Consulting

Results 1 to 4 of 4

Thread: convert text to table

  1. #1

    convert text to table

    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
    Attached Files Attached Files

  2. #2
    Microsoft Word MVP 2003-2009 VBAX Guru gmaxey's Avatar
    Joined
    Sep 2005
    Posts
    3,334
    Location
    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
    Greg

    Visit my website: http://gregmaxey.com

  3. #3
    Thank you so much i will try
    Quote Originally Posted by gmaxey View Post
    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

  4. #4
    Knowledge Base Approver VBAX Guru macropod's Avatar
    Joined
    Jul 2008
    Posts
    4,435
    Location
    Kindly read http://www.vbaexpress.com/forum/faq....thelp_faq_item. "please help me solve this problem" is not a meaningful thread title.
    Cheers
    Paul Edstein
    [Fmr MS MVP - Word]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •