我使用visual basic 6将数据导出到excel文件,问题是 everything works fine when i export in debug mode but when i make the exe it hangs and cursor keeps rotating .

我已经给出了下面的导出代码 . 该程序似乎冻结在 SaveAs 行:

On Error GoTo X
Dim iRow As Integer
Dim iCol As Integer
Dim objExcl As Excel.Application
Dim objWk As Excel.Workbook
Dim objSht As Excel.Worksheet
Dim iHead As Integer
Dim vHead As Variant
Dim path As String
Dim VFileNm As String
Dim i As Integer
Dim CmpGstin As String
Set objExcl = New Excel.Application
RptType = 0
Frame6.Visible = True
MDIForm1.Enabled = False
Label3.Caption = "Please wait... Data is Uploading to Excel file"
VFileNm = App.path & "\GSTR2_Excel.xlsx"
Set objWk = objExcl.Workbooks.Open(VFileNm) '"F:\GST_REPORTS\GST_AGENCIES_TAX_NM20\GSTR1_Excel.xlsx")
For i = 1 To 8
    If i = 1 Then
        If TotRcpt > 0 Then
            ChkG2B2b.Value = 1
            Set objSht = objWk.Sheets(2)
        End If
        Next iCol
       Next iRow
   End If
   TotRcpt = 0
Next
cd1.CancelError = True
cd1.FileName = "\GSTR2_" & CmpGstin & "_" & Format(FrmGstRptShow.DTpFrmDt, "MMMMYYYY") & ".xlsx"
cd1.InitDir = ("C:\My Documents")
cd1.Filter = "*.xlsx|*.xlsx"
cd1.FilterIndex = 4
cd1.ShowSave
VFileNm = cd1.FileName
Label3.Caption = "Please Wait... Excel File is Saving"
objWk.SaveAs VFileNm
MsgBox "Export Succecefully "
objWk.Close False
MDIForm1.Enabled = True
Label3.Caption = ""
Set objSht = Nothing
Set objWk = Nothing
Set objExcl = Nothing
Unload Me
X:
'MsgBox Err.Description
MDIForm1.Enabled = True
Label3.Caption = ""
Set objSht = Nothing
Set objWk = Nothing
Set objExcl = Nothing
'objWk.Close False
Unload Me

如果在调试模式期间出现问题,我可以设法解决问题,但是在使用EXE运行它时会发生 .