T
ThriftyFinanceGirl
Let me explain... I have done a "file copy" command to copy a template, then
export into that template.
The file copy command works perfectly, and the new file is saved where it
should be, however, when the Excel application opens, it is opening ANOTHER
copy of the file (and giving it the name "filename"1). Then when the code is
complete I get the save as dialog box and it isn't even pointing to the place
where I made the original copy. Below is my code...(partial of course) Does
anyone see why this is happening?
--------------------------------------------
'name and full path to use to save the xls file
strWorkBook = "\\Nas01\dol_exch\Departments\Accounting\Sales " & _
"Tax\Sales Tax Database\MasterRecons\MasterJE_" & intmonth &
intyear & ".xls"
strTemplate = "\\Nas01\dol_exch\Departments\Accounting\Sales " & _
"Tax\Sales Tax Database\Templates\MasterReconJE.xlt"
'this command copies the file and gives it the new name
FileCopy strTemplate, strWorkBook
blnEXCEL = False
' True = first row will be header row
' (the names of the fields from the recordset)
'False = No header row
blnHeaderRow = False
' Create an EXCEL application object
On Error Resume Next
Set xlx = GetObject(, "Excel.Application")
If Err.Number <> 0 Then
Set xlx = CreateObject("Excel.Application")
blnEXCEL = True
End If
Err.Clear
On Error GoTo 0
' True = visible while processing
' False = hidden while processing
xlx.Visible = True
' Set the EXCEL file to write the data into
Set xlw = xlx.Workbooks.Open(strWorkBook)
Set xls = xlw.Worksheets("VarianceJE")
.........................................................................
export into that template.
The file copy command works perfectly, and the new file is saved where it
should be, however, when the Excel application opens, it is opening ANOTHER
copy of the file (and giving it the name "filename"1). Then when the code is
complete I get the save as dialog box and it isn't even pointing to the place
where I made the original copy. Below is my code...(partial of course) Does
anyone see why this is happening?
--------------------------------------------
'name and full path to use to save the xls file
strWorkBook = "\\Nas01\dol_exch\Departments\Accounting\Sales " & _
"Tax\Sales Tax Database\MasterRecons\MasterJE_" & intmonth &
intyear & ".xls"
strTemplate = "\\Nas01\dol_exch\Departments\Accounting\Sales " & _
"Tax\Sales Tax Database\Templates\MasterReconJE.xlt"
'this command copies the file and gives it the new name
FileCopy strTemplate, strWorkBook
blnEXCEL = False
' True = first row will be header row
' (the names of the fields from the recordset)
'False = No header row
blnHeaderRow = False
' Create an EXCEL application object
On Error Resume Next
Set xlx = GetObject(, "Excel.Application")
If Err.Number <> 0 Then
Set xlx = CreateObject("Excel.Application")
blnEXCEL = True
End If
Err.Clear
On Error GoTo 0
' True = visible while processing
' False = hidden while processing
xlx.Visible = True
' Set the EXCEL file to write the data into
Set xlw = xlx.Workbooks.Open(strWorkBook)
Set xls = xlw.Worksheets("VarianceJE")
.........................................................................