Posts by alinedian

    Re: Microsoft Word VBA radio buttons


    Thanks mate for your reply again,


    Actually this is not a master file, i am creating a word document which will contain Lyrics of songs from various artists.Under this file i have written a code to insert a new page. The newly "inserted page" is just a template with pre-set text boxes and per-defined text pattern where a user can easily type out or copy paste the lyrics of there desired song/artist.


    I am being able to assign this code to a radio button on a certain page and it also does work and inserts new page above that particular page. But the problem is that i want the new page to contain this radio button too. So that if i want to insert another page above that "newly created" page, i can easily do that.


    I am attaching the word document with the macro named as macro1 and sorry i have just joined any forum so i don't the rules of posting the code.


    Thanks

    Re: Microsoft Word VBA radio buttons


    To help you get a visual of what I am seeking,The Word document is dynamic and requires the ability to make changes and allow songs to be deleted or inserted into the word document.


    Here is the idea of how the user will manipulate the document. The user finds a song he/she needs to include in the document. For example we will say the song title is David Bowie-"Let's Dance". The user will open the word document and scroll to where the artist names start with "D". The user will find the page he/she wants to insert a new song in front or after . This should mean each page has 2 buttons. One button perhaps at the top right hand corner of the page that allows an insertion of a page above the current page, and one button perhaps at the bottom right hand corner of the page, that allows an insertion of a page after the current page where the button is pressed.
    Perhaps the user finds the page with Artist and Title named; Dave Matthews-"Grace Is Gone" and decides this new David Bowie song will be inserted before the Dave Matthews song. The user will press the top right button linked to a macro that allows for a new template page to be inserted before this current page, "Dave Matthews". Upon pressing the "add page" button a new page will appear before the "Dave Matthews" song.
    The user then scrolls to the new template page he/she just inserted using the button above. This new template has a textbox in the left hand corner, an Artist and Song Title Heading and then an area for lyrics



    Here is the macro which i have written and recorded.


    Sub Macro1()

    Selection.InsertBreak Type:=wdSectionBreakNextPage
    Selection.MoveLeft Unit:=wdCharacter, Count:=1
    Selection.TypeParagraph
    Selection.TypeParagraph
    Selection.TypeParagraph
    Selection.TypeParagraph
    Selection.TypeParagraph
    Selection.TypeParagraph
    Selection.TypeParagraph
    Selection.TypeParagraph
    Selection.TypeParagraph
    Selection.TypeParagraph
    Selection.TypeParagraph
    Selection.TypeParagraph
    Selection.TypeParagraph
    Selection.TypeParagraph
    Selection.TypeParagraph
    Selection.TypeParagraph
    Selection.TypeParagraph
    Selection.TypeParagraph
    Selection.TypeParagraph
    Selection.MoveUp Unit:=wdLine, Count:=14

    Dim Shp As Shape
    Set Shp = ActiveDocument.Shapes.AddTextbox( _
    Orientation:=msoTextOrientationHorizontal, _
    Left:=50, Top:=50, Width:=90, Height:=54)
    Shp.TextFrame.TextRange.Text = "Key:" & vbCrLf & "BPM:" & vbCrLf & "notes:"
    Shp.TextFrame.TextRange.Font.Name = "Georgia"
    Shp.TextFrame.TextRange.Font.Size = 8
    Set Shp = Nothing


    Selection.Font.Name = "Georgia"
    Selection.Font.Bold = wdToggle
    Selection.Font.UnderlineColor = wdColorAutomatic
    Selection.Font.Underline = wdUnderlineSingle
    Selection.Font.Size = 18
    Selection.ParagraphFormat.Alignment = wdAlignParagraphCenter
    Selection.TypeText Text:="Artist & Title"
    Selection.Style = ActiveDocument.Styles("Heading 1")
    Selection.TypeParagraph
    Selection.TypeParagraph
    Selection.Font.UnderlineColor = wdColorAutomatic
    Selection.Font.Underline = wdUnderlineNone
    Selection.Font.Bold = wdToggle
    Selection.Font.Size = 12
    With Selection.ParagraphFormat
    .LeftIndent = InchesToPoints(0)
    .RightIndent = InchesToPoints(0)
    .SpaceBefore = 0
    .SpaceBeforeAuto = False
    .SpaceAfter = 0
    .SpaceAfterAuto = False
    .LineSpacingRule = wdLineSpace1pt5
    .Alignment = wdAlignParagraphCenter
    .WidowControl = True
    .KeepWithNext = False
    .KeepTogether = False
    .PageBreakBefore = False
    .NoLineNumber = False
    .Hyphenation = True
    .FirstLineIndent = InchesToPoints(0)
    .OutlineLevel = wdOutlineLevelBodyText
    .CharacterUnitLeftIndent = 0
    .CharacterUnitRightIndent = 0
    .CharacterUnitFirstLineIndent = 0
    .LineUnitBefore = 0
    .LineUnitAfter = 0
    .MirrorIndents = False
    .TextboxTightWrap = wdTightNone
    End With

    Selection.Font.Bold = wdToggle
    Selection.TypeText Text:="Lyrics"
    Selection.TypeParagraph
    Selection.TypeText Text:="Lyrics"
    Selection.TypeParagraph
    Selection.TypeText Text:="{Chorus}"
    Selection.TypeParagraph
    Selection.TypeText Text:="Lyrics"
    Selection.TypeParagraph
    Selection.TypeText Text:="[Bridge]"
    Selection.TypeParagraph
    Selection.TypeText Text:="Lyrics"
    Selection.TypeParagraph
    Selection.TypeText Text:="{Chorus}"
    Selection.TypeParagraph
    Selection.TypeText Text:="Outro"
    Selection.Delete Unit:=wdCharacter, Count:=1
    Selection.Delete Unit:=wdCharacter, Count:=1
    Selection.Delete Unit:=wdCharacter, Count:=1
    Selection.Delete Unit:=wdCharacter, Count:=1
    Selection.Delete Unit:=wdCharacter, Count:=1
    Selection.Delete Unit:=wdCharacter, Count:=1
    Selection.Delete Unit:=wdCharacter, Count:=1
    Selection.Delete Unit:=wdCharacter, Count:=1
    Selection.Delete Unit:=wdCharacter, Count:=1
    Selection.Delete Unit:=wdCharacter, Count:=1
    Selection.Delete Unit:=wdCharacter, Count:=1
    Selection.Delete Unit:=wdCharacter, Count:=1
    Selection.Delete Unit:=wdCharacter, Count:=1



    End Sub

    I am currently working on to make a VBA code to insert new page with some text boxes and code. I simply want the code to be assigned to the radio button. But if i make a radio button on the current page, On assigning the code to it, it works and inserts the new page above the current page. But it doesn't show another radio button on the newly created page. I want the this radio button to be populate to each new page i insert upon clicking.


    I wrote a code that is named "Macro1"


    then i assigned the code to the radio button on page2.


    Code
    private sub CommandButton1_click()           Call Macro1
               End Sub

    #


    Can someone take a look on this ?