Hi All,
I have been searching all over for a solution to my problem but can't find it anywhere. I am fairly new to access and VBA so please help.
I have a macro that exports a number of queries into an excel file saved on my desktop (Position Trend.xls). Currently the macro exports the queries and saves the file before opening it. What I want is for the macro to export the queries and either save the file as a new name (prompted or unprompted) or to not save the file at all, i.e. I want the original template to remain untouched.
I don't know if this is possible or if there's a more logical way of doing things but any advice will be appreciated.
CODE:
Public Sub ExportTblToExcel()
Const FILE_PATH As String = "C:\Users\o588860\Desktop\Rough Work\"
Dim oApp As Object
Dim FULLPath As String
strFullPath = FILE_PATH
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel7, "Position_Trend", strFullPath & "PositionTrend.xls", False
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel7, "Bonds_Static_Data", strFullPath & "PositionTrend.xls", False
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel7, "PricingTrend", strFullPath & "PositionTrend.xls", False
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel7, "LiborCCY", strFullPath & "PositionTrend.xls", False
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel7, "Position_FVA", strFullPath & "PositionTrend.xls", False
DoCmd.SetWarnings True
Set oApp = CreateObject("Excel.Application")
oApp.Visible = True
oApp.workbooks.Open "C:\Users\o588860\Desktop\Rough Work\PositionTrend.xls"
End Sub
Thanks!
Joe
I have been searching all over for a solution to my problem but can't find it anywhere. I am fairly new to access and VBA so please help.
I have a macro that exports a number of queries into an excel file saved on my desktop (Position Trend.xls). Currently the macro exports the queries and saves the file before opening it. What I want is for the macro to export the queries and either save the file as a new name (prompted or unprompted) or to not save the file at all, i.e. I want the original template to remain untouched.
I don't know if this is possible or if there's a more logical way of doing things but any advice will be appreciated.
CODE:
Public Sub ExportTblToExcel()
Const FILE_PATH As String = "C:\Users\o588860\Desktop\Rough Work\"
Dim oApp As Object
Dim FULLPath As String
strFullPath = FILE_PATH
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel7, "Position_Trend", strFullPath & "PositionTrend.xls", False
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel7, "Bonds_Static_Data", strFullPath & "PositionTrend.xls", False
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel7, "PricingTrend", strFullPath & "PositionTrend.xls", False
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel7, "LiborCCY", strFullPath & "PositionTrend.xls", False
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel7, "Position_FVA", strFullPath & "PositionTrend.xls", False
DoCmd.SetWarnings True
Set oApp = CreateObject("Excel.Application")
oApp.Visible = True
oApp.workbooks.Open "C:\Users\o588860\Desktop\Rough Work\PositionTrend.xls"
End Sub
Thanks!
Joe