Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ
Tải xuống
Tham khảo tài liệu 'excel add-in development in c/c++ applications in finance phần 2', công nghệ thông tin, kỹ thuật lập trình phục vụ nhu cầu học tập, nghiên cứu và làm việc hiệu quả | 20 Excel Add-in Development in C C Commands are allowed to do just about anything in Excel. Functions are given far less freedom. VB functions are given a little more freedom than DLL add-ins. Some of the details of the differences between these two are discussed in the later chapters on VB and C C . It is easy to see why there needs to be some difference between functions and commands it would be a bad thing to allow a function in a worksheet cell to press the undo icon whenever it was calculated. On the other hand allowing a user-defined command to do this is perfectly reasonable. Most but not all of this book is concerned with writing functions rather than commands simply because commands are better written in VB and may well require dialog boxes and such things to interact with the user. Chapter 3 Using VBA on page 41 does talk about VB commands but not in great detail there are plenty of books which talk at great length about these things. Later chapters concerning the C API do talk about commands but the focus is on worksheet functions. Table 2.11 gives a non-exhaustive summary of the things that commands can do that functions can t. Table 2.11 Capabilities of commands versus functions Action Command Function Open or close a workbook Yes No Create or delete a worksheet Yes No Change the current selection Yes No Change the format of a cell worksheet or other object Yes No Take arguments when called No Yes Return a value to the caller No Yes Access a cell value not via an argument Yes C API Sometimes2 VBA Yes Change a cell value Yes Only the calling cell or array and only by return value Read write files Yes Yes Start another application or thread Yes Yes Set up event-driven Windows call-backs Yes Yes Call a command-equivalent Excel 4 macro C API function or Excel object method Yes No 2 Worksheet functions are more limited than macro sheet functions in their ability to access the values of other cells not passed in as arguments. For more details on this subject