View Single Post
 
Old 11-13-2015, 04:38 AM
ChrisJ83 ChrisJ83 is offline Windows 7 64bit Office 2013
Novice
 
Join Date: Nov 2015
Posts: 9
ChrisJ83 is on a distinguished road
Default

Sorry to post again, do you know how I would incorporate this into my existing code?

I have tried the following and it prompts me to enter the text however it doesn't actually put the text in the document. It completes the rest of the macro completely though.

Code:
Selection.HomeKey Unit:=wdStory
With ActiveDocument.PageSetup
.TopMargin = CentimetersToPoints(5)
.BottomMargin = CentimetersToPoints(3)
.LeftMargin = CentimetersToPoints(2.31)
.RightMargin = CentimetersToPoints(2.31)
.HeaderDistance = CentimetersToPoints(2.54)
.FooterDistance = CentimetersToPoints(0)
ActiveDocument.Tables(1).Delete
End With
    Selection.Style = ActiveDocument.Styles("Normal")
    Dim TopLineText As String
    Dim Reference As String
    TopLineText = InputBox("Top Line Text?", "")
    Reference = InputBox("Reference?", "")
    Selection.Font.Name = "Arial"
    Selection.Font.Size = 10
    If Trim(TopLineText) <> "" Then Selection.InsertAfter TopLineText & vbCr
    Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, Text:= _
    "MERGEFIELD LQCASE_NAME", PreserveFormatting:=True
    ActiveWindow.View.ShowFieldCodes = Not ActiveWindow.View.ShowFieldCodes
    Selection.TypeParagraph
    Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, Text:= _
    "MERGEFIELD ADD", PreserveFormatting:=True
    ActiveWindow.View.ShowFieldCodes = Not ActiveWindow.View.ShowFieldCodes
    Selection.TypeParagraph
    Selection.TypeParagraph
    Selection.TypeParagraph
    Selection.TypeParagraph
    Selection.TypeParagraph
    Selection.TypeText Text:="Our Ref:      "
    Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, Text:= _
    "MERGEFIELD LQCASE_MAN_SEN", PreserveFormatting:=True
    ActiveWindow.View.ShowFieldCodes = Not ActiveWindow.View.ShowFieldCodes
    Selection.TypeText Text:="/"
    Selection.TypeText Text:=Reference
    Selection.TypeText Text:="/"
    Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, Text:= _
    "MERGEFIELD LQCASE_CASECODE", PreserveFormatting:=True
    ActiveWindow.View.ShowFieldCodes = Not ActiveWindow.View.ShowFieldCodes
    Selection.TypeParagraph
    Selection.TypeParagraph
    Selection.TypeText Text:="Your Ref:     "
    Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, Text:= _
    "MERGEFIELD CREF", PreserveFormatting:=True
    ActiveWindow.View.ShowFieldCodes = Not ActiveWindow.View.ShowFieldCodes
    Selection.TypeParagraph
    Selection.TypeParagraph
    Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, Text:= _
    "DATE  \@ ""dd MMMM yyyy"" ", PreserveFormatting:=True
    Selection.TypeParagraph
    Selection.TypeParagraph
    Selection.TypeParagraph
    Selection.HomeKey Unit:=wdStory
        Selection.Style = ActiveDocument.Styles("Normal")
    ActiveDocument.Tables.Add Range:=Selection.Range, NumRows:=1, NumColumns:= _
        1, DefaultTableBehavior:=wdWord9TableBehavior, AutoFitBehavior:= _
        wdAutoFitFixed
    With Selection.Tables(1)
        If .Style <> "Table Grid" Then
            .Style = "Table Grid"
        End If
        .ApplyStyleHeadingRows = True
        .ApplyStyleLastRow = False
        .ApplyStyleFirstColumn = True
        .ApplyStyleLastColumn = False
        .ApplyStyleRowBands = True
        .ApplyStyleColumnBands = False
    End With
    With Selection.Tables(1).Rows
        .WrapAroundText = True
        .HorizontalPosition = CentimetersToPoints(14.78)
        .RelativeHorizontalPosition = wdRelativeHorizontalPositionPage
        .DistanceLeft = CentimetersToPoints(0.32)
        .DistanceRight = CentimetersToPoints(0.32)
        .VerticalPosition = CentimetersToPoints(-0.85)
        .RelativeVerticalPosition = wdRelativeVerticalPositionParagraph
        .DistanceTop = CentimetersToPoints(0)
        .DistanceBottom = CentimetersToPoints(0)
        .AllowOverlap = True
    End With
    With Selection.Tables(1)
        .TopPadding = CentimetersToPoints(0)
        .BottomPadding = CentimetersToPoints(0)
        .LeftPadding = CentimetersToPoints(0.19)
        .RightPadding = CentimetersToPoints(0.19)
        .Spacing = 0
        .AllowPageBreaks = True
        .AllowAutoFit = True
    End With
    Selection.Tables(1).Rows.HeightRule = wdRowHeightAtLeast
    Selection.Tables(1).Rows.Height = CentimetersToPoints(2.55)
    Selection.Tables(1).Columns(1).PreferredWidthType = wdPreferredWidthPoints
    Selection.Tables(1).Columns(1).PreferredWidth = CentimetersToPoints(5.13)
    Selection.Range.Cells(1).PreferredWidthType = wdPreferredWidthPoints
    Selection.Range.Cells(1).PreferredWidth = CentimetersToPoints(5.13)
    Selection.Borders(wdBorderTop).LineStyle = wdLineStyleNone
    Selection.Borders(wdBorderLeft).LineStyle = wdLineStyleNone
    Selection.Borders(wdBorderBottom).LineStyle = wdLineStyleNone
    Selection.Borders(wdBorderRight).LineStyle = wdLineStyleNone
    Selection.Borders(wdBorderDiagonalDown).LineStyle = wdLineStyleNone
    Selection.Borders(wdBorderDiagonalUp).LineStyle = wdLineStyleNone
    Selection.Font.Name = "Arial"
    Selection.Font.Size = 10
    Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, Text:= _
    "MERGEFIELD GENERAL_ADD", PreserveFormatting:=True
    ActiveWindow.View.ShowFieldCodes = Not ActiveWindow.View.ShowFieldCodes
    Selection.TypeParagraph
    Selection.TypeParagraph
    Selection.Font.Bold = wdToggle
    Selection.TypeText Text:="T: "
    Selection.Font.Bold = wdToggle
    Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, Text:= _
    "MERGEFIELD GENERAL_TEL1", PreserveFormatting:=True
    ActiveWindow.View.ShowFieldCodes = Not ActiveWindow.View.ShowFieldCodes
    Selection.TypeParagraph
    Selection.Font.Bold = wdToggle
    Selection.TypeText Text:="F: "
    Selection.Font.Bold = wdToggle
    Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, Text:= _
    "MERGEFIELD GENERAL_TEL2", PreserveFormatting:=True
    ActiveWindow.View.ShowFieldCodes = Not ActiveWindow.View.ShowFieldCodes
End Sub
Reply With Quote