Results 1 to 2 of 2

"Submit" Macro - Word form data to Excel

Threaded View

Greed "Submit" Macro - Word form... 12-22-2011, 09:59 AM
Domski Re: "Submit" Macro - Word... 12-22-2011, 10:19 AM
  1. #1
    Forum Contributor
    Join Date
    07-15-2011
    Location
    Whitby, Canada
    MS-Off Ver
    Excel 2010
    Posts
    121

    "Submit" Macro - Word form data to Excel

    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
    Attached Files Attached Files
    Last edited by Greed; 12-22-2011 at 10:25 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1