Snowflake68
Registered User.
- Local time
- Today, 16:09
- Joined
- May 28, 2014
- Messages
- 464
The code below exports data to an Excel workbook with 3 tabs. The code works without any issues however when you open up the Excel file for the very first time it has all 3 tabs are selected and you cannot use any of the buttons on the Data tab ribbon until you select one on the tabs. Not a real issue but the manager of my end users have asked me if there is anything I can do to stop this as this sometimes confuses the less familiar users.
Code:
Private Sub cmdPortFolioOutput_Click()
On Error GoTo Errorhandler
DoCmd.SetWarnings False
Dim outputFileName As String
strOutputFileName = [Application].[CurrentProject].[Path] & "\DE_Data\Portfolio\OUT\PortFolioTemplate_" & DLookup("[CustomerFileName]", "1_CustomerProspectSelection") & "_" & DLookup("[LISTREFERENCE]", "LookupListRef") & ".xlsx"
DoCmd.OpenQuery "qry_PortFolioOutputCreated"
cboPortFolioOutput.Locked = True
PortFolioOutputCreated.Visible = True
cmdPortFolioImport.Visible = True
lblDataIn.Visible = True ' Show export DIR link
DoCmd.OpenQuery "qry_Portfolio_MainLive"
DoCmd.OpenQuery "qry_Portfolio_Clearance"
DoCmd.OpenQuery "qry_Portfolio_LimitedAvailability"
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel12Xml, "Portfolio_MainLive", strOutputFileName, True
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel12Xml, "Portfolio_LimitedAvailability", strOutputFileName, True
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel12Xml, "Portfolio_Clearance", strOutputFileName, True
MsgBox "Portfolio Template Created", vbInformation, "PortFolio Template"
Requery
DoCmd.SetWarnings True
Exit Sub
Errorhandler:
MsgBox "Error " & Err.Number & Err.Description
Exit Sub
End Sub