開発環境:ACCESS2003、WindowsXP
ACCESSのフォームからDDEでEXCELのデータを取得し、テーブルへ入れた後、フォームを更新させると、画面がちらつくのですが、ちらつかない方法はあるでしょうか?よろしくお願いします。
Private Sub command_Click()
Dim ch1 As Long
Dim ch2 As Long
Dim strExcelPath As String
Dim strExcelSheet As String
Dim strFilePath As String
Dim i As Integer
Dim j As Integer
Dim celData As Variant
Dim cn As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim tableName As String
Set cn = CurrentProject.Connection
tableName = "****"
rs.Open tableName, cn, adOpenKeyset, adLockOptimistic
strExcelPath = "****"
strExcelSheet = "****"
strFilePath = "****"
Shell strExcelPath, 1
ch1 = DDEInitiate("Excel", "System")
DDEExecute ch1, "[open(""" & strFilePath & """)]"
ch2 = DDEInitiate("Excel", strExcelSheet)
celData = DDERequest(ch2, "R1C1")
rs.AddNew
rs.Fields(0) = celData
rs.Update
DDETerminate ch1
DDETerminate ch2
Me.Refresh
End Sub
すくりーんあっぷでーでぃんぐをふぉるすにする
。さんコメントありがとうございます。
Application.ScreenUpdating = False は
ExcelVBAでは使えますが、AccessVBAでは使えません。
あまり使いたくはなかったのですが
Repaint メソッド使って、更新時のちらつきを抑えました。
一応解決とします。
ツイート | ![]() |