I am trying to open, edit, and save a word document (by calling a module) if a user response is "Yes" using excel 2010 VBA. If the user answers yes then a word document is opened from a location, the user edits it, and then saves the changes to a new location. If it is "No" the VBA moves on to the next line. I don't know if the below is the best way or if it is close, but hopefully it is a start. Thank you
.
VB
'CREATE QC LOG '
iYesNo = MsgBox("Was QC done on this setup?", vbYesNoCancel)
Select Case iYesNo
Case vbYes
Call NewWord
Case vbNo
GoTo Line0
End Select
'CONFIRM ENTRIES '
Dim Patient As String
Dim Barcode As String
Dim Directory As String
Dim MyFile As Variant
Dim MyFolder As String
Dim i As Long
Line0:
Directory =xxxxxxxxxx
NewWord Module
Sub NewWord()
Dim wrdApp As Word.Application
Dim wrdDoc As Word.Document
Dim i As Integer
Set wrdApp = CreateObject("Word.Application") wrdApp.Visible = True
Set wrdDoc = wrdApp.Documents.Add
Set wrdDoc = wrdApp.Documents.Open("C:\aCGH\071683\Reagent QC Form.doc")
For i = 1 To 100 .Content.InsertAfter & i .Content.InsertParagraphAfter Next i If Dir("C:\aCGH\071683\Reagent QC Form.doc") <> "" Then Kill "C:\aCGH\071683\Reagent QC Form.doc" End If .SaveAs ("C:[path]\Reagent QC Form.doc") .Close
End With wrdApp.Quit
Set wrdDoc = Nothing
Set wrdApp = Nothing
End Sub
Bookmarks