Can i export data from a file to a template in excel?
:confused:
Printable View
Can i export data from a file to a template in excel?
:confused:
You can import data from a file using a template in Excel, then save this with all of the template's formatting etc intact - this could be one way to achieve what you're looking for...
Here's one quick example, this opens up excel & then opens a saved template file. Data is copied in (this one is just copying in data from a recordset assumed to be already opened & populated), and the file - with the formatting and data is then saved as a standard *.xls file to a separate folder - should be the type of thing you're after...
VB Code:
Private Sub CommandButton1_Click() Dim objXLApp As Excel.Application Set objXLApp = New Excel.Application With objXLApp .Workbooks.Open "C:\Path\TemplateFile.xlt" .Workbooks(1).Sheets("Sheet1").Range("A1").CopyFromRecordset RecordsetVariable .Workbooks(1).SaveAs "C:\Path2\StandardExcelFormatFile.xls" .Workbooks(1).Close .Quit End With Set objXLApp = Nothing End Sub