Access使用vba停止excel的后台进程

时间:2017-01-26 14:35:59

标签: excel vba background-process access

我编写了一个代码,用于打开excel文件并读取特定字段。问题是每次执行此代码时,在后台启动excel进程,用户都看不到它,但是当你启动任务管理器时,你会看到一个excel进程。我想用VBA关闭这个后台进程。我已经尝试了很多不同的东西,但没有真正的功能。我已经尝试过了:

wb.Close
xcelapp.Application.Quit
Set excelapp = Nothing
Set wb = Nothing

有没有人知道如何用vba关闭excel?

      `Private Sub Command46_Click()
    Dim wert As String

    Dim sfdcID As String
    Dim excelapp As Object
    Dim wb As Object

    wbName = Combo39.Column(0)
    Pfad = "C:\Users\XXXXXX
    Details = "Delivery Input"

    'Open excel
    Set excelapp = CreateObject("excel.application")
    Set wb = excelapp.Workbooks.Open(Pfad)

    'read SFDC Opportunity ID
    Workbooks(wbName).Sheets(Details).Select
    Cells.Find(What:="COMPASS WBS ID").Activate
    ActiveCell.Offset(1, 0).Select
    sfdcID = Selection
    MsgBox sfdcID     

    End Sub`

1 个答案:

答案 0 :(得分:0)

如果您已经运行了Excel进程,那么您的代码将添加另一个进程。 试试这个:

void stud ()
 {
cin.ignore () ; 
cout << "\n\n\nYou must enter information about five students\n\n\n ";
  for (int i = 0; i<5; i++)
    {
        system ("clear") ;

        cout << "-------------------------------------------------\n" ;
        cout <<"Enter information about  "<< (i+1) << " student \n";  
            { 
            cout<<"Enter name and surname\n"; 
             cin.getline(ved[i].name,150) ;

            }

           enter_sex :
             cout <<"Sex (1 - for male/2 - for female) : \n";

             int sex;
             cin >> sex; 
             while (!(cin >> sex) || (cin.peek() != '\n'))
                {
                cin.clear();
                while (cin.get() != '\n');
                        {
                            cout << "\n\nYou must enter 1 OR 2!\nTry again\n\n" << endl;
                            goto enter_sex;
                        }
                } 
                switch (sex)
                {

                    case 1:
                    {
                        ved[i].sex[0] ='m' ;
                        break;
                    }
                    case 2:
                    {
                        ved[i].sex[0] = 'f' ;
                        break;
                    }

                }