Thursday 5 February 2015

Excel Macros (VBA) tips for beginners Part3

Below are some important Excel VBA interview questions which are asked in most MNC company interviews for beginners or professionals.
21. What types of workbook protection are available?
 Excel provides three ways to protect a workbook:
         * Require a password to open the workbook
         * Prevent users from adding sheets, deleting sheets, hiding sheets, and unhiding sheets
         * Prevent users from changing the size or position of windows

22. The Font dialog box allows you to select different Fonts, their style, their size, and some other special effects. How do you bring up this Font dialog box?
 Use Application.Dialogs(xlDialogFont).Show or Application.Dialogs(xlDialogFormatFont).Show to load font dialog box from Excel VBA.

23. What is ADO, OLEDB & ODBC?

ADO : ActiveX Data Objects is universal data access framework that encompasses the functionality of DAO.
ODBC : Open Database Connectivity(ODBC) is a windows technology that lets a database client application connect to a external database.
OLEDB : Low level programming interface designed to access a wide variety of data access Object Linking and Embedding (OLE).

24. How to set the custom paper size in Excel Object through VB?
 Activesheet.PageSetup.PaperSize = xlPaperLetter (Similarly xlPaperA4 or xlPaperLegal etc.)

25. What is the method for returning more than one values from a function in VB?
 Any of the three methods can be used:
i) Create a class with the properties you require to return and then return the object of the class from the function.
ii) Using ByRef for the values.
iii) Return an array of the values.

26. Does VBA supports OOP principles?
 Yes because VBA is VB6.0 based which is an Object Based Programming Language and is also known as 'Event Driven Programming' and it supports Polymorphism, Encapsulation and partially Inheritance.

27. To set the command button for ESC, Which property needs to be changed?
 Set Cancel property of Button to True on the Form.

28. What is Type Library and its purpose?
 Type libraries are files that explicitly describe some or all of the contents of components. This includes information about the methods properties constants and other members exposed by the component. Development tools such as Visual Basic make use of the information contained in the type library to help you as a developer access and use the component. In addition type libraries provide a convenient way to include a simple level of descriptive documentation for component members. You can use them through 'Tools --> References' in VBE.

29. How do you use the Getsetting and Savesetting functions to read and write registry settings?
 A computer registry can be used to store configuration settings and application initialization. We can use Getsetting function to read registry settings and save settings function to write registry settings. Application name, section, key, setting, and default are to be specified for registry modifying. It is advisable to know about your computer settings before modifying registry settings.

30. What is a Variant, what the pros and cons of its use?
 Variant data type is able to hold any other data type, including numbers, strings, dates, and object references. A Variant's descriptor is only 16 bytes long (4 short words for the type, and 2 long words for the data, or data pointer).
Pros: You cannot use Null with any variable type other than Variant.
You don't need to worry about what you have declared a variable as.
When a Variant has been declared but not assigned a value, it contains the special value Empty.
Cons: A developer may not remember and misuse a variable assigning any value to it which will be type-casted without errors.
More Questions & Answers :-
Part1  Part2  Part3  Part4  Part5

No comments:

Post a Comment