我有如下代码,问题在于模板A文件(内只有一个表)被拷贝为B后,打开B文件,发现多出
一个表sheet1,致使数据不能正常写入,请求高手指点!(下面所有变量均定义)。这段
代码在XP下不会出问题,但移植到W98下出问题
Set xlApp = New Excel.Application
Set xlApp = GetObject(, "Excel.Application")
If Err.Number = 0 Then
   xlApp.Quit
   Set xlApp = Nothing
 End If
'清除旧文件
sFilter = "*.XLS"
DelFile = Dir(MyAppPath & "\Prt\" & sFilter, vbNormal)
Do While DelFile <> ""
  Kill MyAppPath & "\Prt\" & DelFile
  DelFile = Dir
Loop
'拷贝模板到目录 MyAppPath & "\Prt下
sBakExclFile = MyAppPath & "\Ini\CqR.XLS"
sCurExclFile = MyAppPath & "\Prt\R" & sYmd & ".XLS"
If Dir(sBakExclFile) <> "" Then
  FileCopy sBakExclFile, sCurExclFile
  Set xlApp = CreateObject("Excel.Application")
  xlApp.Visible = True 'Excel应用程序窗口
  Set xlBook = xlApp.Workbooks.Open(sCurExclFile) '打开工作薄
  Set xlSheet = xlBook.Worksheets("Cqr")
  xlSheet.Cells(5, 2) = YmdStr
  nCurSta = 1  '跟踪区县顺序
  For II = 8 To 30 Step 2
    xlSheet.Cells(II, 2) = CqSta_Cha(nCurSta)  '区县市
    xlSheet.Cells(II, 3) = CqStaR08_08(nCurSta)
    nCurSta = nCurSta + 1
  Next
  xlBook.Save  '保存资料
  xlBook.PrintPreview
  ''xlBook.Close True
  ''xlApp.Quit
  Set xlSheet = Nothing
  Set xlBook = Nothing
  Set xlApp = Nothing
Else
  TxtInf.Text = "模板文件丢失!请与管理者联系。"
End If