VBA等待OLE操作

时间:2019-03-18 20:29:59

标签: excel vba ole

我正在等待OLE Action的情况下通过我的vba代码拔出头发,并且在本工作簿中运行的所有表单上都触发了它。我尝试单击“忽略使用DDE的应用程序”,没有任何附加组件在运行,也没有发送任何内容或与Excel之外的任何程序进行交互。以下是示例代码。我越来越绝望了,很想帮忙!

Private Sub CommandButton3_Click()

Dim companyNumber, contactF1, LastName, title, Email, dphone, cphone, nextcontact As Integer
Dim List As Range: Set List = Worksheets("Database").Range("CompanyNames")
Dim contactrange As Range

companyNumber = WorksheetFunction.Match(ComboBox1, List, 0) + 1 

LastName = 1
title = 2
Email = 3
dphone = 4
cphone = 5
nextcontact = 6

Application.ScreenUpdating = False

Set contactrange = Range(Worksheets("Database").Cells(companyNumber, editrange.Value), Worksheets("Database").Cells(companyNumber, editrange.Value + cphone))

Worksheets("Database").Cells(companyNumber, editrange.Value).Value = NewFName.Value
Worksheets("Database").Cells(companyNumber, editrange.Value + LastName).Value = NewLName.Value
Worksheets("Database").Cells(companyNumber, editrange.Value + title).Value = NewTitle.Value
Worksheets("Database").Cells(companyNumber, editrange.Value + Email).Value = NewContactEmail.Value
Worksheets("Database").Cells(companyNumber, editrange.Value + dphone).Value = NewDirectPhone.Value
Worksheets("Database").Cells(companyNumber, editrange.Value + cphone).Value = NewCellPhone.Value


    If CheckBox1 = True Then
        CreateCandidate.CandidateFName.text = EditContact.NewFName.text
        CreateCandidate.CandidateLName.text = EditContact.NewLName.text
        CreateCandidate.CandidateTitle.text = EditContact.NewTitle.text
        CreateCandidate.CandidateEmail.text = EditContact.NewContactEmail.text
        CreateCandidate.CandidateDphone.text = EditContact.NewDirectPhone.text
        CreateCandidate.CandidateCphone.text = EditContact.NewCellPhone.text
        CreateCandidate.Show
    Else
    End If

    If CheckBox2 = True Then
        contactrange.Delete shift:=xlToLeft
        'add message box confirming deletion!!!!!!!!!
    Else
    End If

EditContact.Hide
editrange.Value = 7
MsgBox "Contact Edited" & vbNewLine & "Changes Saved"

    LookupForm.CNameSearch.text = EditContact.ComboBox1.text
    LookupForm.ContactSearchBtn = True

Call Clear_ALL_Controls
ActiveWorkbook.Save
Application.ScreenUpdating = True
End Sub

0 个答案:

没有答案