我在excel VBA中有一个宏,它可以运行其他宏。我正在尝试实现Application.Screenupdating,以便用户不会看到宏在做什么。但是,它似乎适用于除AccImport以外的所有宏,AcImport是我不希望用户知道的主要宏。
此宏执行从Excel到Access的电子表格传输,并且我不希望我的用户知道我的Access数据库。在此宏中,它通过打开访问数据库,然后关闭它来进行电子表格传输。以下是我触发的主要宏,screenupdating = false似乎适用于AccImport以外的所有宏。
有什么想法吗?谢谢。
Sub ENTER1Dim2()
'
' ENTER1 Macro
'
'
If Worksheets("DIM21").Range("AR32") = 0 Then
MsgBox "Please enter DATA completely first"
End
Else
Application.ScreenUpdating = False
Application.Run "'NEW.xlsm'!TransferE1Dim2"
Application.ScreenUpdating = False
Application.Run "'NEW.xlsm'!PWDOFF"
Application.ScreenUpdating = False
Application.Run "'NEW.xlsm'!ProtectE1Dim2"
Application.ScreenUpdating = False
Application.Run "'NEW.xlsm'!UnprotectE2Dim2"
Application.ScreenUpdating = False
Application.Run "'NEW.xlsm'!ClearE2Dim2"
Sheets("Data1").Select
Application.ScreenUpdating = False
Application.Run "'NEW.xlsm'!AccImport"
Sheets("DIM21").Select
Range("G41").Select
Application.Run "'NEW.xlsm'!PWDON"
Call AUTOSAVE
End If
Application.ScreenUpdating = True
End Sub
下面的宏是AccImport。
Sub AccImport()
'Application.OnTime Now + TimeValue("00:01"), "AccImport"
Dim Acc As New Access.Application
Acc.OpenCurrentDatabase "C:\Users\yilmadu001\Desktop\Database.accdb"
Acc.DoCmd.TransferSpreadsheet _
TransferType:=acImport, _
SpreadSheetType:=acSpreadsheetTypeExcel12Xml, _
TableName:="Table1", _
Filename:=Application.ActiveWorkbook.FullName, _
HasFieldNames:=True, _
Range:="Data1$A1:BL40000"
Acc.CloseCurrentDatabase
Acc.Quit
Set Acc = Nothing
End Sub