Hi,
I'm trying to create separate excel files using access as a front end. So far I have the following code, activated from a command button on a userform.
Private Sub Command78_Click()
Dim objXLApp As Object
Dim objXLBook As Object
Set objXLApp = CreateObject("Excel.Application")
Set objXLBook = objXLApp.Workbooks.Open("C:\Users\Guest\Desktop\VBA apps\TI.xlsx")
objXLApp.Application.Visible = True
' insert data from record
objXLBook.activesheet.Range("A5") = Me.[Job Title]
objXLBook.activesheet.Range("A8") = Me.[SPS No]
objXLBook.activesheet.Range("B9") = Me.[Prg Date]
objXLBook.activesheet.Range("B10") = Me.PM
objXLBook.activesheet.Range("B12") = Me.Team
objXLBook.activesheet.Range("B14") = Me.SAP
objXLBook.activesheet.Range("H9") = Me.[Issue Date]
objXLBook.activesheet.Range("G10") = Me.[PM Tel]
objXLBook.activesheet.Range("G12") = Me.[Team Tel]
objXLBook.activesheet.shapes("titxttask").textframe.characters.Text = Me.Task
objXLBook.activesheet.shapes("titxtnotes").textframe.characters.Text = Me.Notes
'save file as job title with trade identifier
objXLBook.SaveAs ("C:\Users\Guest\Desktop\VBA apps\" & Me.[Job Title] & Me.Trade & ".xlsx")
End Sub
This takes the contents from the fields and inserts them into cells and textboxes in an excel sheet called TI. The workbook is then saved as
[Job Title] Trade.xlsx (for example, Church Road1.xlsx)
This seems to work with one record but I'm not sure how to loop it through several records.
Does anyone know who to write this for more than one record so that the worksheets are created, populated with the data from the records and then saved as separate workbooks in a folder called Task Instructions?
I'm new to this game and have only been using access for about a week so please be gentle with me.
Thanks in advance.
I'm trying to create separate excel files using access as a front end. So far I have the following code, activated from a command button on a userform.
Private Sub Command78_Click()
Dim objXLApp As Object
Dim objXLBook As Object
Set objXLApp = CreateObject("Excel.Application")
Set objXLBook = objXLApp.Workbooks.Open("C:\Users\Guest\Desktop\VBA apps\TI.xlsx")
objXLApp.Application.Visible = True
' insert data from record
objXLBook.activesheet.Range("A5") = Me.[Job Title]
objXLBook.activesheet.Range("A8") = Me.[SPS No]
objXLBook.activesheet.Range("B9") = Me.[Prg Date]
objXLBook.activesheet.Range("B10") = Me.PM
objXLBook.activesheet.Range("B12") = Me.Team
objXLBook.activesheet.Range("B14") = Me.SAP
objXLBook.activesheet.Range("H9") = Me.[Issue Date]
objXLBook.activesheet.Range("G10") = Me.[PM Tel]
objXLBook.activesheet.Range("G12") = Me.[Team Tel]
objXLBook.activesheet.shapes("titxttask").textframe.characters.Text = Me.Task
objXLBook.activesheet.shapes("titxtnotes").textframe.characters.Text = Me.Notes
'save file as job title with trade identifier
objXLBook.SaveAs ("C:\Users\Guest\Desktop\VBA apps\" & Me.[Job Title] & Me.Trade & ".xlsx")
End Sub
This takes the contents from the fields and inserts them into cells and textboxes in an excel sheet called TI. The workbook is then saved as
[Job Title] Trade.xlsx (for example, Church Road1.xlsx)
This seems to work with one record but I'm not sure how to loop it through several records.
Does anyone know who to write this for more than one record so that the worksheets are created, populated with the data from the records and then saved as separate workbooks in a folder called Task Instructions?
I'm new to this game and have only been using access for about a week so please be gentle with me.
Thanks in advance.