Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #4  
Old 11-13-2015, 04:38 AM
ChrisJ83 ChrisJ83 is offline User input box with IF statement Windows 7 64bit User input box with IF statement Office 2013
Novice
User input box with IF statement
 
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
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Variable arrays from user input SeattleITguy Excel Programming 1 01-29-2015 09:19 AM
Taking input from InputBox from user SeattleITguy Excel Programming 1 01-28-2015 09:05 AM
User input box with IF statement vba: user input named argument andrew12345 Excel Programming 2 11-18-2014 08:18 AM
User input box with IF statement User input to a variable on the document dsm1995gst Word VBA 1 09-03-2013 03:43 PM
Look up an array based on user input johnsmb Excel 2 01-07-2011 01:12 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 04:48 PM.


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