Hi all,
I have an issue with a macro - currently used in a Word Form to 'sumit' the form and have the data automatically transfered to an Excel spreadsheet...problem is, I can't seem to make it work - I don't kow what I'm doing well enough. I was hoping someone here might be able to help - document attached - TIA!
Private Sub CommandButton1_Click()
Dim xlapp As Object
Dim xlbook As Object
Dim xlsheet As Object
Dim myarray As Variant
Dim i As Long, lognum As Long
Dim subject As String
subject = InputBox("Enter the subject.")
On Error Resume Next
Set xlapp = GetObject(, "Excel.Application")
If Err Then
bstartApp = True
Set xlapp = CreateObject("Excel.Application")
End If
On Error GoTo 0
Set xlbook = xlapp.Workbooks.Open("Z:\FireClerical\NANCE - LINDA\Gillian\J. Bentley\MSA SCBA Tracking.xls")
Set xlsheet = xlbook.Worksheets(1)
With xlsheet.Range("A1")
i = .CurrentRegion.Rows.Count
If i = 1 Then
lognum = 1
Else
lognum = .Offset(i - 1, 0).Value
lognum = lognum + 1
End If
.Offset(i, 0).Value = lognum
.Offset(i, 1).Value = subject
End With
xlbook.Save
xlbook.Close
If bstartApp = True Then
xlapp.Quit
End If
End Sub
Bookmarks