jim may
Well-known Member
- Joined
- Jul 4, 2004
- Messages
- 7,486
I'm just reveiwing some code in A Standard ACCESS Module, as follows...
and I'm unclear as to:
1) appExcel.Visible = True << What is this doing?
2) Set myDestinationBook = appExcel.Workbooks.Open << I suppose this opens the File referred to in the path which follows (below). Does this Assume that Excel is not previously Open and Running and It Loads it with this one instance? What if it were already Oen before running this? Would there be a problem with the code..?
Sub ExportToMyExcel()
Dim appExcel As New Excel.Application
Dim mySourceBook As Excel.Workbook
Dim myDestinationBook As Excel.Workbook
Dim mySourceSheet As Excel.Worksheet
Dim myDestinationSheet As Excel.Worksheet
Dim Rng1 As Range
Dim Rng2 As Range
'On Error Resume Next
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel12, "qryDataExportedToExcel", _
"C:\Users\James\Documents\Trusted_Locations\CBF\Last_CBF_DB_Export.xlsx", True
appExcel.Visible = True
'appExcel.ScreenUpdating = False
Set myDestinationBook = appExcel.Workbooks.Open(FileName:="C:\Users\James\Documents\Trusted_Locations\CBF\Ministers_Churches_Database_4.xlsm", ReadOnly:=True)
and I'm unclear as to:
1) appExcel.Visible = True << What is this doing?
2) Set myDestinationBook = appExcel.Workbooks.Open << I suppose this opens the File referred to in the path which follows (below). Does this Assume that Excel is not previously Open and Running and It Loads it with this one instance? What if it were already Oen before running this? Would there be a problem with the code..?
Sub ExportToMyExcel()
Dim appExcel As New Excel.Application
Dim mySourceBook As Excel.Workbook
Dim myDestinationBook As Excel.Workbook
Dim mySourceSheet As Excel.Worksheet
Dim myDestinationSheet As Excel.Worksheet
Dim Rng1 As Range
Dim Rng2 As Range
'On Error Resume Next
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel12, "qryDataExportedToExcel", _
"C:\Users\James\Documents\Trusted_Locations\CBF\Last_CBF_DB_Export.xlsx", True
appExcel.Visible = True
'appExcel.ScreenUpdating = False
Set myDestinationBook = appExcel.Workbooks.Open(FileName:="C:\Users\James\Documents\Trusted_Locations\CBF\Ministers_Churches_Database_4.xlsm", ReadOnly:=True)