home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic 4 Unleashed / Visual_Basic_4_Unleashed_SAMS_Publishing_1995.iso / source / chap12 / msword.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1995-09-24  |  3.5 KB  |  110 lines

  1. VERSION 4.00
  2. Begin VB.Form Form1 
  3.    Caption         =   "Form1"
  4.    ClientHeight    =   3990
  5.    ClientLeft      =   3720
  6.    ClientTop       =   6915
  7.    ClientWidth     =   6690
  8.    Height          =   4395
  9.    Left            =   3660
  10.    LinkTopic       =   "Form1"
  11.    ScaleHeight     =   3990
  12.    ScaleWidth      =   6690
  13.    Top             =   6570
  14.    Width           =   6810
  15.    Begin VB.CommandButton Command1 
  16.       Caption         =   "Command1"
  17.       Height          =   495
  18.       Left            =   2760
  19.       TabIndex        =   2
  20.       Top             =   1200
  21.       Width           =   1215
  22.    End
  23.    Begin VB.TextBox Text1 
  24.       Height          =   495
  25.       Left            =   2760
  26.       MultiLine       =   -1  'True
  27.       TabIndex        =   1
  28.       Text            =   "msword.frx":0000
  29.       Top             =   1800
  30.       Width           =   1215
  31.    End
  32.    Begin VB.Label Label1 
  33.       Caption         =   "Label1"
  34.       Height          =   495
  35.       Left            =   2760
  36.       TabIndex        =   0
  37.       Top             =   1800
  38.       Width           =   1215
  39.    End
  40. Attribute VB_Name = "Form1"
  41. Attribute VB_Creatable = False
  42. Attribute VB_Exposed = False
  43. Dim msword As Object
  44. Private Sub wordDelLineWith(oldStuff As String)
  45.     msword.StartOfDocument
  46.     msword.EditFind Find:=oldStuff, Direction:=0, MatchCase:=0, _
  47.         WholeWord:=0, PatternMatch:=0, SoundsLike:=0, Format:=0, Wrap:=0
  48.     msword.StartOfLine
  49.     msword.EndOfLine 1
  50.     msword.EditClear
  51. End Sub
  52. Private Sub wordReplace(oldStuff As String, newStuff As String)
  53.     msword.StartOfDocument
  54.     msword.EditReplace oldStuff, newStuff, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0
  55. End Sub
  56. Private Sub Command1_Click()
  57.     Set msword = CreateObject("word.basic")
  58.     With msword
  59.         .AppMaximize
  60.         .FileNew Template:="Letter2", NewTemplate:=0
  61.     End With
  62.     ' Replace all of the easy stuff. This is all fixed information
  63.     wordReplace "[Company Name]", "Barside Brewery"
  64.     wordReplace "[Street Address]", "123 Lite Road"
  65.     wordReplace "[City, State/Province Zip/Postal Code]", "Pub City, Montana  43255"
  66.     wordReplace "[Recipient Name]", "Jack Tremor"
  67.     wordReplace "[Address]", "1414 Runner Drive"
  68.     wordReplace "[City, State/Province Zip/Postal Code]", "Boston, MASS 12321"
  69.     wordReplace "[Recipient]", "Jack"
  70.     wordReplace "[Your name]", "Rose Switz"
  71.     wordReplace "[Your position]", "Shipping Coordinator"
  72.     wordReplace "[Typist
  73. s initials]", "dmm"
  74.     wordReplace "[Number]", "0"
  75.     wordDelLineWith "cc:"
  76.     wordDelLineWith "[Type"
  77.     With msword
  78.         .INSERT Text1.TEXT
  79.         .InsertPara
  80.         .FilePrint
  81.         .FileClose 2
  82.     End With
  83.     Set msword = Nothing
  84. End Sub
  85. Private Sub Form_Load()
  86.     Label1.AutoSize = True
  87.     Label1.Caption = "Enter the body of the letter below and then click on PRINT."
  88.     Label1.Height = 200
  89.     Label1.Left = 50
  90.     Label1.TOP = 50
  91.     ' Note that this control must be set as
  92.     ' MultiLine=True & ScollBars=2 through
  93.     ' the properties dialog box at design time.
  94.     Text1.Height = 3000
  95.     Text1.Left = 200
  96.     Text1.TEXT = ""
  97.     Text1.TabIndex = 1
  98.     Text1.TOP = Label1.TOP + Label1.Height + 100
  99.     Text1.Width = 4000
  100.     Command1.Caption = " Print Letter"
  101.     Command1.Height = 500
  102.     Command1.Left = 50
  103.     Command1.TabIndex = 2
  104.     Command1.TOP = 3500
  105.     Command1.Width = 4500
  106.     Form1.Caption = "Letter Entry"
  107.     Form1.Height = 4500
  108.     Form1.Width = 4700
  109. End Sub
  110.