Dear frens,
I have successfuly exported a Namelist inside a query Table into an existing excel file but it creates a new worksheet and the data is dumped there.
what if I want to export the data to a named worksheet (already in the existing excel file) and the appropriate cells too eg. A3: A23
Here's the code i have so far ... Feel free to take a look or use...
Thanks in advance for any help ...
Private Sub TransferNameListToExcel_Click()
Dim fileName As String
Dim result As Integer
Dim MyXL As Object
With Application.FileDialog(msoFileDialogFilePicker)
.Title = "Select Excel File to export Name List to"
.Filters.Clear
.Filters.Add "All Files", "*.*"
.Filters.Add "Excel", "*.xls"
.Filters.Add "Excel Template", "*.xlt"
.FilterIndex = 3
.AllowMultiSelect = False
.InitialFileName = CurrentProject.Path
result = .Show
If (result <> 0) Then
fileName = Trim(.SelectedItems.Item(1))
DoCmd.TransferSpreadsheet acExport, , "Evaluasi Query", fileName
Set MyXL = GetObject(fileName)
MyXL.Application.Visible = True
MyXL.Parent.Windows(1).Visible = True
End If
End With
End Sub
I have successfuly exported a Namelist inside a query Table into an existing excel file but it creates a new worksheet and the data is dumped there.
what if I want to export the data to a named worksheet (already in the existing excel file) and the appropriate cells too eg. A3: A23
Here's the code i have so far ... Feel free to take a look or use...
Thanks in advance for any help ...
Private Sub TransferNameListToExcel_Click()
Dim fileName As String
Dim result As Integer
Dim MyXL As Object
With Application.FileDialog(msoFileDialogFilePicker)
.Title = "Select Excel File to export Name List to"
.Filters.Clear
.Filters.Add "All Files", "*.*"
.Filters.Add "Excel", "*.xls"
.Filters.Add "Excel Template", "*.xlt"
.FilterIndex = 3
.AllowMultiSelect = False
.InitialFileName = CurrentProject.Path
result = .Show
If (result <> 0) Then
fileName = Trim(.SelectedItems.Item(1))
DoCmd.TransferSpreadsheet acExport, , "Evaluasi Query", fileName
Set MyXL = GetObject(fileName)
MyXL.Application.Visible = True
MyXL.Parent.Windows(1).Visible = True
End If
End With
End Sub