Recent Updates Toggle Comment Threads | Keyboard Shortcuts

  • Syed Muhammad Numan 7:46 am on November 11, 2014 Permalink |
    Tags: ,   

    Excel: A Pop-Up Calendar for MS-Excel 2007 & up 

    This is the upgraded version of my other collection of Excel Pop-up calendar. This has been posted in a site where I have collected if from for my own personal reference.

    One of the biggest problems in maintaining “good” data is the entry of dates. People seem to get confused about entering dates. Should they enter dd/mm/yy or mm/dd/yy? Do they enter slashes or dashes or dots? And what was the date of the third Thursday in September last year anyway? What you really need is a calendar!

    NOTE: Microsoft has created an alternative to the Calendar Control called the MonthView control. This new ActiveX control is similar in function to the Calendar Control and has the advantage that it is installed with all versions of Microsoft Office. In Microsoft Office 2007 you have the choice of which ActiveX control to use but in Microsoft Office 2010 you must use the MonthView control as described in this tutorial.

    The tutorial shows you how to create a pop-up calendar using the Microsoft MonthView control that is installed with Excel. You will use the Visual Basic Editor to create a UserForm that displays a calendar. You will also write some VBA code to power the UserForm and to generate an additional item on the menu that appears when the user right-clicks a cell on an Excel worksheet. Clicking the menu item will display the calendar. When the user selects a date it is automatically entered into the active cell on the worksheet.

    A pop-up calendar for entering dates into Excel cells.

    What Will the Calendar Do?

    The MonthView control has a number of useful features. In its standard format it displays a single month in calendar format (it can be set to display more than one if required). Either side of the month name is an arrow button which displays the previous or next month when clicked. Clicking on the month name opens a list of months so that you can quickly jump to a specific month. Clicking on the year number reveals a spinner which lets you change the year. The current date is always shown at the bottom of the calendar. Click it to jump to today’s date on the calendar.

    Click the arrows to go back or forward a month.Click the month name to change the month.Click the year number to change the year.Click today's date to jump to today.

    Where Does the Code Go?

    The pop-up calendar is created entirely with code and is generated when you need it. The code that creates and operates the calendar has to reside inside an Excel file. The question is which one? If you want the pop-up calendar to be available whenever you are working in Excel you should create it in Personal.xlsb, sometimes referred to as your Personal Macro Workbook, because this file exists to store code that you want to be available to all your Excel files. Personal.xlsb opens and is hidden each time Excel is started. Any macros and functions it contains are then available for use in any other workbook. To find out whether or not you already have a copy of Personal.xlsb read the instructions in New to VBA? further down the page.

    However since the Personal Macro Workbook, as its name implies, is specific to your copy of Excel it will reside either on your computer’s hard drive or within your personal profile on the network. It isn’t the best place to put the code if you want other users to have access to the pop-up calendar. Instead, you could create your pop-up calendar in a specific workbook. It would be available whenever (and only when) that workbook was open, but also available to any other workbook that was open at the same time. A pop-up calendar created in an Excel template would be present in each workbook that was generated from the template. The most flexible option is to create an Excel Add-In. It’s easy to do and will allow you to distribute your calendar to other users. You start by building the calendar exactly as described in this tutorial but in a new Excel workbook (not Personal.xlsb) which you then convert to an Excel Add-In. The last section of this tutorial takes you through the steps of creating an Excel Add-In.

    In this tutorial I will be using Personal.xlsb but if you choose to put your pop-up calendar somewhere else you can still follow the same instructions.

    New to VBA?

    If you plan to create and edit macros or work with VBA code you will find it useful to enable the Developer tab. It offers quick access to many of the tools you will be using during your projects. If it isn’t currently visible in your copy of Excel you can enable it by going to Excel Options.

    • In Excel 2007 click the Office Button and choose Excel Options. Click the Popular button, check the Show Developer tab in the Ribbon option then click OK to return to Excel.
    • In Excel 2010 go to the File tab and choose Options and select the Customize Ribbon section. On the right side of the window under Customize the Ribbon make sure that Main Tabs is selected from the dropdown then check the Developer option and click OK to return to Excel.
    Enable the Developer tab in Excel 2007. Enable the Developer tab in Excel 2010.

    If you have never recorded a macro on your current copy of Excel then you probably won’t have a copy of Personal.xlsb yet. If a copy exists it will be visible in the Project Explorer window of the Visual Basic Editor. If you don’t have one it takes just a moment to create: On the Developer tab click the Record Macro button. When the Record Macro dialog appears choose to store the macro in the Personal Macro Workbook then click OK. Now click the Stop Recording button on the Developer tab. You have just recorded an empty macro but that action was sufficient to prompt Excel to create a copy of Personal.xlsb to store it in. You can delete the macro later but now you have somewhere to create your pop-up calendar.

    Build the Calendar

    The first step is to build the calendar. When you have done that you will go on to write the VBA code that will make it work. If you plan to create an Excel Add-In you should open a new empty workbook. If you want your calendar to reside in a specific workbook then make sure that workbook is open. In Excel open the Visual Basic Editor using the keyboard shortcut [ALT]+[F11] or click the Visual Basic button on the Developer tab of the Ribbon.

    IMPORTANT: Remember to save your work regularly. Since a UserForm and its associated code resides within an Excel workbook the they are saved when you save the workbook and vice-versa. You can save from within Excel or from within the Visual Basic Editor window in the usual way by clicking the Save button. Excel will warn you if there are any unsaved changes when you close the workbook. If you are working in a regular Excel workbook (and not in Personal.xlsb) you should save your workbook as an Excel Macro Enabled Workbook (*.xlsm). Failure to do this will result in Excel discarding your code.

    Step 1. Create a new UserForm

    You are going to place the pop-up calendar on a UserForm which is a kind of dialog box that you can build and program with VBA. Go to the Project Explorerwindow of the Visual Basic Editor. The Project Explorer is usually located in the upper left corner of the Visual Basic Editor window. If you can’t see it, switch it on from the View menu. Right-click on the name of the workbook in which you want to create the pop-up calendar then choose Insert and UserForm.

    Insert a new UserForm.

    A new empty UserForm will appear in the main window of the Visual Basic Editor together with the Toolbox containing buttons for the most commonly used objects (called controls) that can be placed on a form. You can switch the Toolbox on and off from a button on the toolbar. You will also notice that the Toolbox disappears when the UserForm is not selected. If this happens just click on the UserForm and the Toolbox will reappear.

    Step 2. Rename and caption the UserForm

    When the UserForm is selected the Properties Window of the Visual Basic Editor displays a list of all the UserForm’s properties. The Properties Window is normally located in the lower left corner of the Visual Basic Editor window. If you can’t see it switch it on from the View menu. Excel automatically names and captions (where appropriate) new objects. You will see that the UserForm has been given the name and caption UserForm1. It is good practice to give objects more meaningful names so go to the Properties Window and change the Name property to frmCalendar and the Caption property to Pick a Date…

    IMPORTANT: If you choose to use different names from those suggested here remember to modify any code that refers to these objects by name.

    You can test the Userform from the Visual Basic Editor now (and at any stage) by pressing [F5] on your keyboard or clicking the Run button on the toolbar. Doing this opens the UserForm in Excel so that you can check the progress of your design. Closing the UserForm (click the [X] in its upper-right corner) returns you to the Visual Basic Editor.

    Step 3: Place a Close button on the UserForm

    You might think the calendar doesn’t need a Close button since there is already one in the upper-right corner of the UserForm, and our code will close the form automatically after a date has been chosen. But doing so will add a useful feature that most users take for granted, that is to close the calendar if they press the[Esc] key on their keyboard.

    Click the CommandButton button on the Toolbox then click on the center of the UserForm. The dots on the UserForm represent a grid to help you align objects neatly. Point at the dotted border of the new command button and drag it so that it is located two grid points down from the top and two grid points in from the left of the UserForm.

    Now use the Properties Window to change the command button’s Name property to cmdClose, change its Caption property to Close and set its Cancel property toTrue. When the Cancel property of a command button is set to True the button gets clicked automatically when the user presses the [Esc] key on their keyboard.

    The UserForm has a new caption and a Close button.

    Step 4: Code and test the Close button

    In this step you will attach some code to the Cancel button so that when it is clicked the UserForm will close, thus closing the pop-up calendar. In the Visual Basic Editor double-click the Close command button. This opens the UserForm’s code window with an empty Event Procedure for the Click event of the command button (an Event Procedure is a collection of commands that are executed when a particular event happens – in this case when the cmdClose button is clicked).

    Between the Sub… and End Sub lines enter the statement:

          Unload Me

    This instructs Excel to close the UserForm. The completed code should look like this:

    Private Sub cmdClose_Click()
    Unload Me
    End Sub

    Return to the UserForm design window by double-clicking its name in the Project Explorer or by using the keyboard shortcut [CTRL]+[TAB] to switch windows, then test the UserForm as before by pressing [F5] or clicking the Run button on the toolbar. You should be able to close the UserForm from Excel by either clicking theClose button or by pressing the [ESC] key.

    HOW THE CODE WORKS
    The command Unload causes a UserForm to close and drop out of memory (the command Hide can be used to be remove it temporarily from view yet have it remain open in memory so that it can be reopened without losing its data). The word Me is a quick way of referring to the current UserForm without having to use its full name. I could have written Unload frmCalendar. Since the form is usually referred to frequently in the code using Me simplifies code writing and saves a lot of editing if the UserForm’s name is ever changed.

    Step 5: Locate the MonthView control

    The MonthView control will provide the calendar that you will place on the UserForm. It is not normally present on the Toolbox so you will have to ask for it. Right-click on the Toolbox and choose Additional Controls. Scroll down the list in the Additional Controls dialog until you find Microsoft MonthView Control 6.0 (the version number might be different depending on your version of Microsoft Office) and check the box next to its name, then click OK to close the dialog. You will see that a button for the new control has been added to the toolbox.

    Add the MonthView control to the Toolbox.

    Step 6: Place a calendar on the UserForm and set its properties

    Click the MonthView button on the Toolbox then click on the UserForm to create a calendar on the form. Drag the calendar into the upper left corner to the UserForm. The calendar will cover the Close button you created earlier. This is intentional because the Close button will be operated by the user pressing their [ESC]key and it does not need to be visible.

    When the MonthView control is selected the Properties Window displays its properties. By default it has a sunken border. I don’t like this effect so I have changed theAppearance property to 0 – cc2Flat. There are many other properties you can modify. The MonthColumns and MonthRows properties allow you to display more than one month at a time. The ShowToday property lets you choose whether or not to highlight and display the current date.

    Position the MonthView control on the UserForm.

    Step 7: Resize the UserForm

    The final step in designing the calendar is to change the size of the UserForm to match the dimensions of the calendar. Click on the background of the UserForm to select the form then use the resizing handles (white rectangles located around the dotted border) to drag the edges of the UserForm to the required size. Finally, run the form to check that it looks OK.

    Resize the UserForm to match the calendar.

    Step 8: Write the code to enter a date

    In this step you will create the code that writes a date on to the worksheet when the user clicks one of the day buttons on the calendar. Double-click the MonthView control to open the code window. This opens the UserForm’s code window with an empty Event Procedure for the DateClick event of the MonthView control.

    You have a couple of choices now depending upon what you want to happen when the user chooses a date. If you want the calendar to enter the chosen date only in the active cell, which is the selected cell when only a single cell is selected or only the active cell if a block of cells or multiple cells are selected, then use this method. Between the Sub… and End Sub lines enter the statements:

          On Error Resume Next
    ActiveCell.Value = DateClicked
    Unload Me

    This instructs Excel to enter the chosen date into the currently active cell and the close the UserForm. The completed code should look like this:

    Private Sub MonthView1_DateClick(ByVal DateClicked As Date)
    On Error Resume Next
    ActiveCell.Value = DateClicked
    Unload Me
    End Sub

    If you want the calendar to enter the chosen date in all the currently selected cells, whether this is a block of cells, a multiple selection, or just a single cell if only one is selected, then use this method. This code is more versatile so I would probably do it this way unless I had a particular reason not to do so. Between the Sub… andEnd Sub lines enter the statements:

          On Error Resume Next
    Dim cell As Object
    For Each cell In Selection.Cells
    cell.Value = DateClicked
    Next cell
    Unload Me

    This instructs Excel to write a date into each of the selected cells. Your code should look like this:

    Private Sub MonthView1_DateClick(ByVal DateClicked As Date)
    On Error Resume Next
    Dim cell As Object
    For Each cell In Selection.Cells
    cell.Value = DateClicked
    Next cell
    Unload Me
    End Sub

    Test the code by running the calendar as before, with one or several cells selected. If it fails to work properly then check your typing!

    HOW THE CODE WORKS
    Although this is a very simple operation, in both cases I have added the statement On Error Resume Next which tells Excel to ignore any error that might occur. This will prevent the code from crashing if, for example, the selected cell or one of the cells in a selection is locked. The code makes use of theDateClicked parameter which is given the date chosen when the user clicks one of the day buttons. In the first example that value is simply written into the active cell before the UserForm is closed. In the second example the code first declares a variable that represents a single cell. It then employs a For…Nextcode loop to visit each cell in the current selection, entering the value into each as it goes, before finally closing the UserForm.

    Step 9: Synchronize the calendar with the worksheet

    I nearly didn’t include this step, which is optional anyway, because whilst it works perfectly on the old version of my pop-up calendar it doesn’t work completely as it should in this version. The idea is that, if the active cell already contains a date, the calendar opens to display that same date. I have been able to make the calendar display the correct month and year but despite my best efforts can’t get it to highlight the specific day. The MonthView control has a DayBold property which is “supposed” to be controllable with code – you tell the calendar which day number to display in bold and it does so – but in the current context I just can’t make it work. I’ve searched for a solution without success so if you find one please let me know! Here’s how to have the calendar open at the correct year and month…

    Open the UserForm’s code window by right-clicking on its name in the Project Explorer and choosing View Code or pressing the [F7] key. At the top of the code window are two drop-down lists. From the left-hand list choose UserForm the from the right-hand list choose Initialize. This creates and empty event procedure for the UserForm_Initialize event (if a UserForm_Click event is also created you can delete it). Between the Sub… and End Sub statements type:

          If IsDate(ActiveCell.Value) Then
    Me.MonthView1.Value = ActiveCell.Value
    End If

    Your completed code should look like this:

    Private Sub UserForm_Initialize()
    If IsDate(ActiveCell.Value) Then
    Me.MonthView1.Value = ActiveCell.Value
    End If
    End Sub

    Test the code in different scenarios: by opening the calendar when the active cell in Excel is empty; when it contains something that is not a date (a number or some text); and when it contains a date different from the current date. If the active cell is empty, or contains text or a number, the calendar should open to show the current date. If the active cell already contains a date the calendar should open to show the same year and month.

    The calendar displays today's date.The calendar matches its date with the active cell.

    HOW THE CODE WORKS
    The Initialize event happens as the UserForm opens. It is used to prepare the form for use with such tasks as filling lists and setting starting values for textboxes. Here it is being used set the initial value of the MonthView control. The code uses the IsDate function to check whether or not the active cell contains a date. This is used as the condition for an If Statement so that, if the function returns True, the value of the calendar is set to the same date. If the function returns False then no date was found so nothing changes and the calendar opens with its default date.

    Step 10: Write the code to open the calendar

    Until now you have been opening the pop-up calendar from from the Visual Basic Editor but we need a way to open it from Excel. This will take the form of a simple macro. In the Project Explorer right-click on the name of the workbook in which you created the UserForm then choose Insert and Module. This creates a new code module which then opens in the main window of the Visual Basic Editor. Type:

          Sub OpenCalendar

    and press [Enter]. Excel places a pair of brackets after your typing and after an empty line adds the line End Sub. Place your cursor in the empty line between Sub…and End Sub and enter the following statement:

          frmCalendar.Show

    If you gave your UserForm a different name make sure you use it here. The completed code should look like this:

    Sub OpenCalendar()
    frmCalendar.Show
    End Sub

    You can test your macro by going to Excel and clicking the Macros button on the View tab or the Developer tab. Your macro will be listed in the Macro dialog box. Select it then click Run to open the calendar.

    Test the macro that opens the calendar

    HOW THE CODE WORKS
    The Show command is the reverse of the Hide command mentioned earlier. But this time you can’t use Me to refer to the UserForm because it is not the object in which this bit of code resides. The UserForm has to be referred to by name. There is also a Load command which opens a Userform into memory but does not make it visible. It is unnecessary to use it here because, if a UserForm is not already open in memory when the Show command is given, Excel assumes that it must Load it first and does so automatically.

    Step 11: Write the code for the shortcut menu

    Now that there is a macro to open the calendar we can add some features to make it more convenient for the user to run it. One way is to add a new command to the Cell context menu, the one that the user sees after right-clicking on a cell. This means writing some code to add a new item to the menu when the file containing the calendar opens, and some more code to remove the menu item when the file closes. This code has to run automatically when the file opens or closes so we make use of special event procedures that are located in the ThisWorkbook code module.

    In the Visual Basic Editor go to the Project Explorer and click the plus sign [+] next to the folder marked Microsoft Excel Objects under the name of the file containing your calendar. When the folder opens double-click the item marked ThisWorkbook to open the code module in the main window. Choose Workbookfrom the left-hand drop-down list at the top of the window. This automatically creates an empty event procedure for the Workbook_Open event. Between theSub… and End Sub statements type:

          On Error Resume Next
    Dim NewControl As CommandBarControl
    Application.CommandBars(“Cell”).Controls(“Insert Date”).Delete
    Set NewControl = Application.CommandBars(“Cell”).Controls.Add
    With NewControl
    .Caption = “Insert Date”
    .OnAction = “Module1.OpenCalendar”
    .BeginGroup = True
    End With

    Your completed code should look like this:

    Private Sub Workbook_Open()
       On Error Resume Next
       Dim NewControl As CommandBarControl
    Application.CommandBars(“Cell”).Controls(“Insert Date”).Delete
       Set NewControl = Application.CommandBars(“Cell”).Controls.Add
       With NewControl
    .Caption = “Insert Date”
    .OnAction = “Module1.OpenCalendar”
    .BeginGroup = True
    End With
    End Sub

    IMPORTANT: If you changed any of the names within your project you must make sure you also edit the code so that the matching names are used. So, if you called your macro anything other than “OpenCalendar” or the module in which it is located is called anything other than “Module1”, you should amend the code accordingly. Make sure, for example, that the text “Insert Date” is spelled the same way each time it is used. Simple errors like this are the most common reason for code not working

    HOW THE CODE WORKS
    The Workbook_Open event happens automatically when a workbook opens in Excel. As before, the code starts with an instruction to ignore any errors that might occur (you should always use this command with caution and only when you are sure that nothing untoward can happen if an error is ignored). Then a Dim statement is used to declare a variable which I have called “NewControl” and which represents a menu item. Before proceeding to create the new menu item the next statement deletes the item from the menu. This seems illogical but it is a safety measure to make sure that, if Excel did not close properly last time, we are not left with multiple copies of the menu item. If, as expected, Excel closed properly and the menu item was deleted then this statement would cause an error to occur, hence the error handler at the start. The next statement adds the item to the menu. A With Statement (a way of grouping together a number of commands relating to the same thing) is used to set the properties of the new menu item.

    Now go to the right-hand drop-down list at the top of the code window and choose BeforeClose to create an event procedure for the Workbook_BeforeCloseevent. Between the Sub… and End Sub statements type:

          On Error Resume Next
    Application.CommandBars(“Cell”).Controls(“Insert Date”).Delete

    Your completed code should look like this:

    Private Sub Workbook_BeforeClose(Cancel As Boolean)
       On Error Resume Next
    Application.CommandBars(“Cell”).Controls(“Insert Date”).Delete
    End Sub

    HOW THE CODE WORKS
    The Workbook_BeforeClose event happens automatically as a workbook closes. This procedure simply deletes the new item from the menu and is protected with a simple error handler.

    Step 12: Add a keyboard shortcut to activate the calendar

    If you like using keyboard shortcuts then you might like to have one automatically assigned to your pop-up calendar. This requires an additional command statement to be added to the Workbook_Open event procedure. Add the following line to the Workbook_Open event procedure. Either below the Dim… statement or immediately above the End Sub statement:

          Application.OnKey “+^{C}”, “Module1.OpenCalendar”

    You also need to cancel the shortcut assignment when the file containing the calendar closes so add the following line to the Workbook_BeforeClose event procedure:

    Application.OnKey “+^{C}”

    The completed code should look like this:

    Private Sub Workbook_BeforeClose(Cancel As Boolean)
    On Error Resume Next
    Application.OnKey “+^{C}”
    Application.CommandBars(“Cell”).Controls(“Insert Date”).Delete
    End Sub

    Private Sub Workbook_Open()
    On Error Resume Next
    Dim NewControl As CommandBarControl
    Application.OnKey “+^{C}”, “Module1.OpenCalendar”
    Application.CommandBars(“Cell”).Controls(“Insert Date”).Delete
    Set NewControl = Application.CommandBars(“Cell”).Controls.Add
    With NewControl
    .Caption = “Insert Date”
    .OnAction = “Module1.OpenCalendar”
    .BeginGroup = True
    End With
    End Sub

    HOW THE CODE WORKS
    The OnKey command is used to instruct Excel to run a specific macro when a particular combination of keys is pressed. The key combination is defined by a code, in this case +^{C} which represents the shortcut [SHIFT]+[CTRL]+[C]. The plus sign represents the [SHIFT] key, the caret (^) represents the [CONTROL] or [CTRL] key, and the {C} represents the letter C. If you prefer a different shortcut then you can specify something else. If you would like to see a complete list of the key codes that can be used go to your code module and place you cursor within the word OnKey in the code, then press [F1]. This opens Help at the appropriate page. The OnKey command is used in the Workbook_Open event procedure to assign the keyboard shortcut to the macro that opens the calendar, and again in the Workbook_BeforeClose event procedure, but this time without the macro assignment, to cancel the assignment when it is no longer needed.

    Step 13: Test the code

    Before testing your code you should CHECK YOUR TYPING, especially anything you have typed in quotes, such as the caption you used for the menu item! The Visual Basic Editor is good at spotting coding errors but can’t check your text entries. It is far better to find and correct any errors now than after your code has crashed and maybe caused problems in your worksheet. You can additionally check any new code by compiling it. Open the Debug menu and choose Compile VBA Project. If you get no messages then the editor has not found any problems. If the Compile… entry is disabled it means that there is nothing new to compile.

    Compile and Save your code then close Excel. This ensures that Personal.xlsb is closed. If you are working in a file other than your Personal.xlsb then you need only close and save that file. Re-open Excel (or re-open the file in which you created the calendar if it was not Personal.xlsb) and right-click on any cell. You should see the command Insert Date at the bottom of the context menu. Choose it to make your calendar appear. When you pick a date from the calendar the date will be written into the cell and the calendar will close. If you added the keyboard shortcut to open the calendar then test that too by holding down the [CONTROL] and [SHIFT] keys and pressing [C].

    If any of this does not work then the most likely problem is a typing error in your code. Go back and check it thoroughly!

    The new command appears on the cell's right-click menu.

    Step 14: Password protect the code

    If it is likely that other users will have access to your code projects and particularly if you intend to distribute your project either as a shared file, template or Add-In, it is advisable to protect your code with a password. This has a number of advantages. It prevents a third party from viewing and possibly interfering with the code. It also guarantees that, in the unfortunate event that an unforeseen error causes the code to crash, the user does not find themselves in the Visual Basic Editor looking at a stalled code module and not knowing what to do next.

    In the Visual Basic Editor go to the Project Explorer then right-click on the name of the file containing your pop-up calendar project and choose VBAProject Properties. Select the Protection tab of the Properties dialog and enter then confirm your password. Place a tick in the Lock project for viewing check box then click OK and Save the file.

    Password protect the code.

    The password protection comes into operation after the protected file has been closed and re-opened. If you try to view the code of a protected code project the Visual Basic Editor requires you first to supply the password.

    A password is required to view the code.

    IMPORTANT: Don’t forget the password! If you lose the password to a VBA code project you will permanently lock yourself out of the code. There is no easy way to recover the password of a protected file which, after all, is the point of protecting it.

    That’s it! You’ve finished and should have a fully-functioning pop-up calendar. If you want to continue and turn it into an Add-In then read on…

    Building an Excel Add-In

    The following steps explain how to convert your project into an Add-In which you can use yourself or distribute to other users. If you have been working so far inPersonal.xlsb you don’t need to build the calendar again. Just copy or move your UserForm and associated code into a regular Excel workbook. It isn’t difficult to do. Open a new, empty workbook in Excel then in the Visual Basic Editor go to the Properties Window and drag the UserForm from Personal.xlsb to your new workbook where Excel will create a copy of it. All the UserForm’s code will automatically go with it. Do the same for the module in which you created the macro that opens the calendar (Module1 in this example). Then copy the Workbook_Open and Workbook_BeforeClose code from the ThisWorkbook module in Personal.xlsb to the ThisWorkbook module of your new workbook.

    IMPORTANT: If you plan to use the Add-In yourself you should delete the UserForm and all the associated code from Personal.xlsb to eliminate any risk of conflicts between them.

    If you have been working in a regular Excel workbook then you don’t need to do anything else, just follow on from here.

    Step 15: Save the file and define its properties

    If you have been working in a regular Excel workbook you will already have saved the file. If not, or if you have just copied everything into a new workbook fromPersonal.xlsb then you need to save it now. Save the file as an Excel Macro Enabled Workbook (*.xlsm) and call it something like Calendar.xlsm. It is possible to miss out this step but I recommend it because it gives you a back-up copy of your work and also allows you to add a meaningful name and a description to your Add-In. Then Close the workbook.

    Use Windows Explorer to find the workbook you just saved then right-click on it and choose Properties. In the File Properties dialog click the Summary tab and enter some suitable information about your Add-In. Alternatively you can you can access the file properties from within Excel when the file is open:

    • In Excel 2007 click the Office Button then choose Prepare and Properties. In the Properties pane click Document Properties then Advanced Properties to open the Properties dialog.
    • In Excel 2010 go to the File tab, click Info then choose Properties and Advanced Properties to open the Properties dialog.

    The Title property will become the name of the Add-In (as distinct from its filename) and the Comments property will be used to provide the user with a brief description of its features. After defining the properties remember to save the file!

    Add a name and description to the file.

    Step 16: Create the Add-In file

    To create the Add-In open your Calendar.xlsm file in Excel then open the Save As dialog box:

    • In Excel 2007 click the Office Button then choose Save As and Other Formats.
    • In Excel 2010 go to the File tab and choose Save As.

    If you want to give your Add-In a different filename you can do it now. Open the Save as type dropdown and choose Excel Add-In (*.xlam) from the list then clickSave. Excel creates a copy of the file (the original remains unchanged) as an Add-In and automatically stores it in the Add-Ins folder. The location of the Add-Ins folder might be different depending on your particular set-up but it is usually found at: C:\Users\<Username>\AppData\Roaming\Microsoft\Add-Ins.

    Save the file as an Add-In.

    The location of an Add-In is important but not critical since, as you will see shortly, you can tell Excel where to find an Add-In if it is not in the usual place. This is useful if, for example, you want to store your Add-Ins in a network location.

    NOTE: You will see that there is also the option to save the file as an Excel 97-2003 Add-In (*.xla). Don’t do this unless you know that it is going to be used in an older version of Excel (Excel 2003 or earlier). The Add-In needs to be in the right format for the version of Excel in which it will be used.

    Step 17: Activate the Add-In

    Now that you have built the Add-In it must be activated in Excel before you can use it. If you are going to distribute your Add-In the users will need to do this on each computer in which the Add-In is installed.

    • In Excel 2007 click the Office Button and choose Excel Options.
    • In Excel 2010 go to the File tab and choose Options.

    Go to the Add-Ins section of the Excel Options dialog. If you have installed the Add-In file in the default Add-Ins folder you will see it listed here under the Inactive Application Add-Ins heading (don’t worry if you put it somewhere else – you will be able to browse for it later). You can click on its name here to view details of its location and the properties you assigned earlier.

    The Add-In appears in the Inactive Application Add-Ins list.

    Make sure that Excel Add-Ins is selected in the Manage list then click Go to open the Add-Ins dialog in Excel. If you installed the Add-In in the default Add-Ins folder it will be listed in the dialog box. Otherwise, click the Browse button to locate and select your Add-In file which will appear in the dialog when you have done so. You will also see any other Add-Ins that have already been installed including those that come pre-installed with Excel. Selecting one displays its features at the bottom of the dialog box. Now that Excel knows about your Add-In you can switch it on and off from here. Doing so effectively opens and closes the Add-In file in Excel. To switch your Add-In on place a tick in the box next to its name and click OK.

    The Add-Ins dialog in Excel.

    NOTE: In Excel 2010 the Developer tab of the Ribbon has a button (marked Add-Ins) that takes you direct to the Add-Ins dialog.

    The pop-up calendar is now ready for use and will remain so each time you use Excel until you deactivate it by un-checking the box next to its name in the Add-Insdialog box. If you return to the Add-Ins section of the Excel Options dialog you will see that your Add-In now appears under the heading Active Application Add-Ins.

    The Add-In appears in the Active Application Add-Ins list.

     
  • Syed Muhammad Numan 10:38 am on October 1, 2014 Permalink |
    Tags: , ff, ie, webssearch   

    How to remove istart.webssearch from your browsers! 

    Very thankfully webssearch has provided with the removal methods on their site. Here is the summary of all it.

    Uninstall from IE

    IE Homepage and default search
    1. Open IE Explore.
    2. Click “Tools->Internet Options”,Open “Internet Options” panel.
    3. Click “General” tab.
    4. Delete webssearches homepage link and set a new homepage link , or click “Use blank”.
    5. Click “Settings” button in the “Search” area,open “Manage Add-ons” panel.
    6. Choose webssearches and click “Remove” , then close “Manage Add-ons” panel.
    7. Click “Apply” or “OK” on “Internet Opens” panel to save the changes.

    Uninstall from Chrome

    Chrome Homepage and default search
    1. Open Chrome explore.
    2. Click “Customize and control Google Chrome” in the right-top of the page and click “Setting”.
    3. Click “Set pages” link of “On startup” ->delete webssearches homepage link ->click “OK”.
    4. Click “Change” link of “Apperance” -> delete webssearches homepage link -> click “OK”.
    5. Click “Manage search engines”->delete webssearches,then click “OK”.
    6. Restart Chrome explore.

    Uninstall from Firefox

    Firefox Homepage and default search
    1. Open Firefox explore.
    2. Click “Firefox->Options->Options” open “Options” panel.
    3. Click “General” tab.
    4. Delete webssearches homepage link and set a new homepage link. Or click “Restore to Default”.
    5. Click “OK”.
    6. Choose “Manage Search Engines” in the search list.
    7. Remove webssearches,then click “OK”.
    8. Restart Firefox explore.
     
  • Syed Muhammad Numan 5:58 am on September 9, 2014 Permalink |
    Tags: Data Form, , QAT   

    Excel: Data Form 

    Copied from : Office Watch

    Microsoft is embarrassed about the Excel data form feature (rightly so) and so they hide it away where customers can’t easily find it.

    Excel 2007 and Excel 2010

    In recent versions of Excel, the data form feature is hidden away. The easiest workaround is to put it in the Quick Access Toolbar (QAT). Click on the wedge at the right of the QAT and choose ‘More Commands’.

    Select the ‘Commands Not in the Ribbon’ list and scroll down to ‘Form …’ then add that button to the QAT list on the right.

    Suppressed Image:

    Now the Excel data form is on the Quick Access Toolbar. You can click on it within any Excel worksheet with a data list and headings to make the pre-populated form appear.

    Excel 2003

    In Excel 2003 and Excel 2002 right-click on the toolbar and choose ‘Customize …’ at the bottom. Click on the Commands tab then select the category ‘Data’. Click on ‘Form …’ on the right and drag it to wherever you like on the toolbar or menu.

    Suppressed Image:

     
  • Syed Muhammad Numan 12:54 pm on September 6, 2014 Permalink |
    Tags: , Excel 2003,   

    Excel: Pop-Up calendar for pre 2003 version of MS-Excel 

    Like everyone, I have copied excel codes from different tutorials online. Here is one I did for a consistency of precise and nice work, but till today I have had the link lost. Since I found it back I want to make a reference to it here and make a copy for my own reference.

    The tutorial of this calendar was specifically written for Excel 2003 and earlier versions. However, I shall collect the newer one for Excel 2007 or later version since they have that one there too.

    One of the biggest problems in maintaining “good” data is the entry of dates. People seem to get confused about entering dates. Should they enter dd/mm/yy or mm/dd/yy? Do they enter slashes or dashes or dots? And what was the date of the third Thursday in September last year anyway? What you really need is a calendar!

    This tutorial shows you how to create a pop-up calendar using the Microsoft ActiveX Calendar Control that is installed with Excel. The user will be able to call up the calendar with a keyboard shortcut, from a toolbar button or menu, or from the right-click context menu. When the user selects a date it is automatically entered into the active cell on the worksheet…

    A pop-up calendar for entering dates into Excel cells

    Where Does the Code Go?

    The code that creates and operates the calendar has to reside inside an Excel file. The question is which one? If you want the pop-up calendar to be available whenever you are working in Excel you should create it in Personal.xls, sometimes referred to as your Personal Macro Workbook, because this files exists to store code that you want to be available to all your Excel files. Personal.xls opens and is hidden each time Excel is started. Any macros and functions it contains are then available for use in any other workbook.

    Alternatively, you could create your pop-up calendar in a specific workbook. It would be available whenever (and only) when that workbook was open, but also available to any other workbook that was open at the same time.

    In this tutorial I will be using Personal.xls but if you choose to put your pop-up calendar somewhere else you can still follow the same instructions.

    If you want to distribute your calendar, you should consider saving it as an Excel Add-In.

    Prepare the Workbook (Personal.xls)

    You can miss out this step if you want to store your calendar in a different workbook. Otherwise, start Excel and go to Tools > Macro > Visual Basic Editor(Keys: Alt+F11) to open the Visual Basic Editor.

    First you need to check if a copy of Personal.xls already exists. If there isn’t one you will have to create one (it’s quite easy!). Look at the Project Explorer window (normally on the upper left of the Visual Basic Editor window).

    The Project Explorer window showing Personal.xlsIf you can see VBAProject (PERSONAL.XLS) you already have a copy. If there is no Personal.xls then you need to could create one. Here’s a quick way to do it…

    Switch to Excel and go to Tools > Macro > Record New Macro. When the Record Macro dialog box opens choose Store Macro in: Personal Macro Workbook, click <OK>, then click the Stop Recording button (the one with the small blue square) on the macro recording toolbar. This procedure forces Excel to create a copy of the Personal.xls file.

    Switch back to the Visual Basic Editor and use the Project Explorer to navigate to Module1 in Personal.xls. Double-click it to open the code window where you will see the macro you just recorded. Select the lines fromSub Macro1() to End Sub and press the [DELETE] key to remove it.

    Build the Calendar and Write its Code

    Step 1: Insert a New UserForm

    Inserting a UserFormvbatut07c.gif (22096 bytes)The calendar is going to be displayed on a VBA UserForm. In the Project Explorer click on VBAProject (PERSONAL.XLS) then go to Insert > UserForm to open a new blank UserForm [click the thumbnail below to see a full-sized image of the Visual Basic Editor window]…

    Make the following changes in the Properties Window…
    Name: frmCalendar
    Caption: Select a Date

    Step 2: Locate the Calendar Control Tool

    You need to draw a Calendar Control (active objects on forms are called “controls”) on the UserForm, but the one you need is not normally included in the Toolbox. To install it, first make sure that the Toolbox is visible. If it isn’t, switch it on with View > Toolbox. Then go to Tools > Additional Controls. In the dialog box find Calendar Control 8.0 (for Excel 97 and 2000, Calendar Control 10.0 for Excel 2002) and select it. Click the <OK>button to close the dialog. This adds a new button to the toolbox, labelled Calendar.

    NOTE: The Calendar Control is an ActiveX control (actually a file called mscal.ocx) supplied with Microsoft Office. It is normally installed with a standard installation of Microsoft Office Professional or Microsoft Access, but if you can’t find it on the list you will need to get hold of a copy. If you are distributing your file, or planning to use it on more than one computer, you will also need to make sure that the host computer has the mscal.ocx file installed. You will find it on the CD that your copy of Microsoft Office Professional came on, or you can download a copy from here.

    Step 3: Add a Calendar Control to the UserForm

    Click the Calendar tool then click on the UserForm near its upper left corner to place a calendar on the UserForm.

    Click on the form near the upper left corner... >>> An ActiveX Calendar Control on a UserForm

    Make sure the calendar is selected then take a look at the choices in the properties window. Click on the Custom >category (near the top of the list) and click the […] button to open the calendar control’s custom properties dialog. You can format the calendar any way you like. I made the following changes…

    General – Show Month/Year Title: No
    Font – DayFont Size: Size 8, Not Bold
    Font – GridFont: Size 8

    Omitting the title and making the text smaller allowed me to resize the calendar to a smaller rectangle by dragging the resize handles (white rectangles)…

    Resize the Calendar Control

    Now click on the UserForm itself so that you can see its resizing handles and resize it to fit the calendar…

    Resize the UserForm to fit the calendar

    To get a preview of how the calendar will look click the F5 key. When you do this the UserForm will open in Excel as it would in use. Click the UserForm’s close button ([x]) to return to the Visual Basic Editor.

    Step 4: Add a Command Button

    If the user opens the calendar by mistake, they will be able to close it by clicking the [x] button without entering a date on the worksheet. Most users also expect a form or dialog box to close without making changes if they press the [ESCAPE] key on their keyboard. This doesn’t happen by itself. You have to program the UserForm to respond to this event. To do this you will place a command button on the UserForm which closes it when clicked. By setting the button’s Cancel property to >Yes the effect of the user hitting the [ESCAPE] key will be to programmatically click the button. The user doesn’t need to see the button, so you can hide it behind the calendar.

    Click the Command Button tool on the toolbox then click on the calendar (just left of centre) to place a command button on the UserForm. Note that the command button places itself behind the calendar by default, although you can still see its outline when it is selected…

    Place a Command Button on the UserForm

    With the command button selected, make the following changes in the properties window…

    Name: cmdClose
    Cancel: True

    Step 5: Write Code for the Command Button

    This step adds some code to the Click event of the command button so that when clicked (i.e. when the user hits the [ESCAPE] key) the UserForm closes without anything else happening.

    Go to View > Code (Keys: F7) to open the UserForm’s code window. If the command button was still selected there will already be an entry. If not, choose cmdClose from the left hand (General) drop-down list at the top of the code window. It should automatically select Click from the right-hand (Declarations) list. Place your cursor between the Sub… and End Sub lines and press the [TAB] key to indent your code. Type Unload Me. Your line of code will look like this:

    Code to close the UserForm

    Use [CTRL]+[TAB] (or go to Window > frmCalendar(UserForm)) to switch back to the UserForm window and test the code. Press [F5] to open the form in Excel. Notice that the command button is invisible (it is behind the calendar). Press the [ESCAPE] key and see that the UserForm closes.

    Step 6: Write Code for the Calendar

    This step builds the code that will transfer the date that the user chooses to the active (selected) cell on the worksheet.

    Return to the UserForm’s code window. Open the left-hand (General) drop-down list at the top of the code window and choose Calendar1. If it is not already selected, choose Click in the right-hand list. This enters the start and end lines of the Calendar1_Click procedure.

    Place the cursor between the two lines and press [TAB] to indent your code (indenting blocks of code is good practice – it makes the code easier to read) then type:

    ActiveCell.Value = Calendar1.Value

    …which transfers the date selected on the calendar to the active cell. On the next line type:

    Unload Me

    …which closes the form. Your code should look like this:

    Code to insert the date and close the form

    To make the calendar a bit more user-friendly you will now add some code that checks to see if the active cell already contains a date. If it does, then the calendar will show the same date when it opens. If there is no date in the cell (or if what is in the cell isn’t a date) the calendar will show today’s date. To do this we make use of the UserForm’s Initialize event, which happens as the UserForm opens.

    Open the left-hand drop-down list at the top of the code window and choose UserForm, then open the right-hand list and choose Initialize. (You will notice that when you chose “Initialize” the start and end lines for the UserForm_Click procedure were created. You don’t need these so it is safe to delete them.)

    Place your cursor between the start and end lines of the UserForm_Initialize procedure and type the following:

    If IsDate(ActiveCell.Value) Then
    Calendar1.Value = DateValue(ActiveCell.Value)
    Else
    Calendar1.Value = Date
    End If

    This IF Statement checks the active cell for a date. If it is a date then the calendar displays the same date. If not it uses the VBA Date function to display the current date. Your completed code should look like this:

    Code to check for an existing date

    Now you need to write some code to display the UserForm on demand. If you had to create Personal.xls you will already have a code module (Module1). Otherwise, or if you are using a different workbook, go to Insert > Module to create one. Double-click the name of the module in the Project Explorer window to open its code window (or right-click it and choose View Code).

    Type the line Sub OpenCalendar and press enter. The Visual Basic Editor places a pair of brackets at the end of the line and adds the line End Sub, placing your cursor between them. Press [TAB] then type frmCalendar.Show. Your code should look like this:

    Code to display the UserForm

    This simple procedure will display the UserForm when run from Excel.

    Step 7: Test the Code

    At this point it is a good idea to save your file in case something goes wrong! In the Visual Basic Editor window go to File > Save PERSONAL.XLS (or whatever your file is called).

    Switch to Excel and select an empty cell in which to enter a date. Go to Tools > Macro > Macros (Keys: Alt + F8) to open the Macro dialog. Make sure that the macro PERSONAL.XLS!OpenCalendar is selected and click <Run>.

    The Macro dialog ready to run the OpenCalendar procedure

    When the calendar opens it will display today’s date. Choose a date (NOTE: always choose month and year before choosing day because clicking on a day fires the Calendar1_Click event). When you click the day the calendar closes and enters your date into the cell.

    Now select a cell that already contains a date and run the macro. When the calendar opens it displays the date that was already in the cell. If you wish you can choose another date, or you can press the [ESCAPE] key to close the calendar without making any changes.

    Adding Extra Features

    Adding a Toolbar Button or Menu Item

    A useful addition is a toolbar button and/or menu item that lets the user call the macro that opens the UserForm. They don’t need to know that they are calling a macro – they will just be using your new Insert Date tool!

    To create a toolbar button:

    Go to View > Toolbars > Customize and choose the Commands tab on the Customize dialog. In the left-hand window scroll down to Macros and select it. You will see two items in the right-hand window, one for a new button and the other for a new menu item.

    Selecting a custom macro button in the Customize dialog

    Drag Custom Button from the dialog box to a position on one of your toolbars then release the mouse button to place the new button on the toolbar. You can rearrange and edit your toolbars and menus as much as you want when the Customize dialog is open…

    Drag the custom button to a toolbar location >>> A new custom button in position

    You must link the button to the macro, and you will probably want to change its image too:

    • Right-click the button and enter some text (such as Insert Date) in the text box next to Name, then press [ENTER]. This text will be the tool-tip that the user sees when they point at the button.
    • Right-click the button and choose Edit Button Image. This is the fun part. I’ll leave it up to you to figure out how to use this tool, but I can guarantee endless hours of amusement!
      Click the thumbnail to view a full-sized image of the button image editor
    • Right-click the button and choose Assign Macro, choose the name of your macro (in this case PERSONAL.XLS!OpenCalendar) from the list, and click <OK>.

    Here’s what my button looks like:

    A custom button icon for the calendar A custom toolbar button for opening the calendar

    Make any other changes you want and click <Close> on the Customize dialog box. You can now test your button. When you click it the UserForm will open and you can insert a date.

    To create a new menu item:

    Open the Customize dialog as in the previous step and select the Macros category. This time drag Custom Menu Item from the dialog box to one of your menus, but don’t release it yet. The menu will open and allow you to place your new menu item wherever you choose.

    • Right-click the menu item and enter some text (such as &Date) in the text box next to Name, then press [ENTER]. This text will be the title of the menu item. The ampersand (&) does not appear itself but causes the following letter to be underlined (i.e. Date). This allows users to select the menu item by using their keyboard.
    • You can have a button image too if you want. I used the same image as for my custom button. To do this right-click on the button and choose Copy Button Image then right-click on the menu item and choose Paste Button Image.
    • Right-click the menu item and choose Assign Macro, choose the name of your macro (in this case PERSONAL.XLS!OpenCalendar) from the list, and click <OK>.

    Here’s how it looks…

    Positioning a new menu item on an existing menu > The new menu item in position > The finished menu item with a custom button image

    Close the Customize dialog box and test your menu item.

    Assigning Keyboard Shortcut

    You can also assign a keyboard shortcut. There are two ways to do this. You can do it manually or have the workbook assign a shortcut when it is opened. The advantage of the latter method is that, if the calendar is contained in its own workbook, the shortcut applies only when the workbook is open. It also means that the shortcut is applied automatically on which ever computer the file is being used – handy for files that are being distributed and for add-ins too.

    To assign a shortcut manually:

    In Excel go to Tools > Macro > Macros to open the Macro dialog. Select the name of your macro (in this case PERSONAL.XLS!OpenCalendar) then click the <Options> button. This lets you assign a keyboard shortcut and an optional description to a macro. Assign the shortcut by clicking in the small white box and typing the key combination you want to use. In the illustration below I have assigned the shortcut [CTRL]+[SHIFT]+[C]….

    Manually assigning a keyboard shortcut

    To assign a shortcut with code:

    In the Visual Basic Editor find the This Workbook entry for PERSONAL.XLS (or your chosen workbook) in the project explorer and double click it (or right-click and choose View Code) to open its code window. Open the left-hand (General) drop-down list at the top of the code window and choose Workbook. This creates the start and end lines for the Workbook_Open procedure. This is a special macro that runs automatically whenever the workbook is opened. Between the start and end lines type the line:

    Application.OnKey "+^{C}", "Module1.OpenCalendar"

    The + sign signifies Shift, the ^ signifies CTRL and {C} signifies the letter C. You can use any key combination you like. Your code should look something like this:

    Code to assign a keyboard shortcut

    You will need to save and close the workbook and then reopen it before you can try it out. If you are using PERSONAL.XLS you will need to close Excel and reopen it. Save the file first!

    Adding the Calendar to the Shortcut Menu

    Using VBA you can add custom items to shortcut menus (the menu you see when you right-click on something, sometimes called context menus). Here’s how to add an item to the “Cell” shortcut menu (the one which appears when you right-click on a worksheet cell). The menu item will call the macro that opens the calendar’s UserForm.

    Is is a good idea to place the code that creates the shortcut menu item in the Workbook_Open macro, so that the menu item is added whenever the workbook is opened. But to ensure that the item appears only once (the menu item is persistent – a duplicate would be created each time you opened the file!) you should also create a procedure to remove the menu item when the file closes. To do this you can create a Workbook_BeforeClose macro, which runs automatically when its host workbook closes.

    Code to create the new shortcut menu item:

    If you have created a keyboard shortcut with code (in the previous step) you will already have a Workbook_Open macro. If not, create one as described above (you can omit the line that assigns a keyboard shortcut if you want).

    Add lines to the Workbook_Open procedure as follows:

    If necessary, make an empty line above the existing code, and enter as the first line the variable declaration:

    Dim NewControl as CommandBarControl

    The next line of code, which can be entered below your shortcut key code, tells Excel that the variable is a new item (or control) to be added to the right-click menu of a cell:

    Set NewControl = Application.CommandBars("Cell").Controls.Add

    Now some code to describe the new item:

    With NewControl
    .Caption = "Insert Date"
    .OnAction = "Module1.OpenCalendar"
    .BeginGroup = True
    End With

    The Caption is the text which appears on the menu, and can be anything you want. Make sure that OnAction correctly specifies your macro’s name and location. The optional BeginGroup >puts a separator line above the new item on the menu. Your finished code should look like this:

    Here’s how the resulting shortcut menu looks:

    A shortcut to the pop-up calendar on the cell context menu

    Code to remove the new shortcut menu item:

    This procedure reverses the action of the code in the previous step. This is necessary because items added to the shortcut menu will remain there even when the workbook that created them is not open. Choosing the shortcut would then result in an error (although not a serious one… the user would see a message to the effect that Excel couldn’t find the macro). Also, because the workbook creates the menu item as it opens, you would end up with several copies of the item if you didn’t remove it as the workbook closed.

    In the same module as the Workbook_Open procedure use the drop-down lists to create a Workbook_BeforeClose procedure. Enter the line:

    On Error Resume Next

    …which tells Excel to ignore any error that might occur (i.e. if it tries to remove the menu item but can’t find one). Then enter the line:

    Application.CommandBars("Cell").Controls("Insert Date").Delete

    …which removes your item from the shortcut menu of a cell. Your finished code should look like this:

    TIP: If you should find yourself with unwanted copies of custom menu items on the shortcut menu (because, like me, you wanted to test the first procedure before you created the second one!). You can give the instruction from the Visual Basic Editor’s Immediate Window (go to View > Immediate Window or Keys: CTRL+G). Click in the Immediate Window and type the line the starting Application… and ending…Delete then press [ENTER].

    Any further info can be found in the original site.

     
  • Syed Muhammad Numan 4:37 pm on June 24, 2014 Permalink |
    Tags: , configuration, httpd, Sendmail   

    CentOS: sendmail conf for httpd 

    Often times when configuring Linux flavoured OS’s we tend to forget some basic switches to turn on. One of them is with sendmail — setsebool . The other one to see the set parameters is — getsebool .

    Running # man setsebool or # man getsebool removes lot of confusion.

    Recently, I have found a sit with a similar situation where I needed to set httpd_can_sendmail to on which is actually done with those boolean operators.😉

     
  • Syed Muhammad Numan 4:17 pm on June 24, 2014 Permalink |
    Tags: , , Linux, RDP, Remote Desktop, , VNC, VNC server   

    CentOS: Installing VNC Server for Remote Desktop access 

    Of many helps available on the internet many are complete, some are not suitable and yet others are not upto the mark. However, I have collected the steps from various sources and compiled herein for reference.

    There are packages required to run the VNC server on CentOS, and here are there installation:

    sudo yum groupinstall Desktop
    sudo yum install tigervnc-server
    sudo yum install xorg-x11-fonts-Type1
    

    Optionally add

    sudo yum install vnc
    

    To make VNC server persistent at startups

    sudo chkconfig vncserver on
    

    Now set VNC password with

    vncpasswd
    

    Now in order for a user to be able to access through VNC to connect the desktop set up a user in the following way. Edit file /etc/sysconfig/vncservers

    sudo vim/etc/sysconfig/vncservers
    

    and add the following to the end of the file:

    VNCSERVERS="1:arbab"
    VNCSERVERARGS[1]="-geometry 1024x600"
    

    Now amend the iptable rules to allow right ports to VNC:

    sudo iptables -I INPUT 5 -m state --state NEW -m tcp -p tcp -m multiport --dports 5901:5903,6001:6003 -j ACCEPT
    sudo service iptables save
    sudo service iptables restart
    

    Now restart the VNC Server:

    sudo service vncserver restart

    In order to start gnome-session properly do the following:

    vncserver -kill :1
    vim .vnc/xstartup
    

    Comment out and add as follows:

    #twm &
    exec gnome-session &

    Restart server:

    sudo service vncserver restart

    Now follow youtube instructions.
    There are many other helps available. Read thru to get a better idea on the subject matter:

     
  • Syed Muhammad Numan 9:03 pm on June 5, 2014 Permalink |
    Tags: , , , , RVM,   

    Ubuntu: RVM installation 

    I was following the RoR lessons from Michael Hartl’s famous and most informative Rails Tutorial on his site. First thing we needed, after IDE setup with SublimeText, is to install the RVM. That is detailed in this post as much as possible in line with the version 4.0 of the tutorial.

    From LinuxCasts I found the following:

    $ sudo apt-get update 				# This will pull a list of updates for your system.
    $ sudo apt-get upgrade 				# This will download install the updates from the previous command.
    $ sudo apt-get install curl 			# This will install the program cURL.
    $ \curl -L https://get.rvm.io | bash -s stable 	# This will tell cURL to go to that web address and download a stable version of RVM.
    $ source ~/.rvm/scripts/rvm 			# This sets the source for rvm to use.
    $ rvm requirements 					# This will check that your system has all of RVM's requirements.
    $ rvm install ruby					# This will use rvm to install ruby.
    $ rvm use ruby --default 				# This will tell rvm to use ruby by default.
    $ rvm rubygems current 				# This will download the latest version of rubygems.
    $ gem install rails 					# This will download the latest version of rails.
    $ sudo apt-get install nodejs 		# This will download the latest version of nodejs.
    

    But that doesn’t actually suffice the RailsTutorial. It needed some modification as follows:

    After the necessary updates of the system in the following way

    $ sudo apt-get update
    $ sudo apt-get upgrade
    $ sudo apt-get install curl
    

    we move on to install the rvm itself

    $ curl -sSL https://get.rvm.io | bash -s stable
    $ rvm requirements
    $ source ~/.rvm/scripts/rvm
    # For Debian-based Linux systems
    $ sudo apt-get install libyaml-dev
    $ rvm install 2.0.0 --with-openssl-dir=$HOME/.rvm/usr
    $ rvm use 2.0.0@railstutorial_rails_4_0 --create --default
    $ rvm rubygems 2.1.9
    $ gem update --system 2.1.9
    

    Suppressing the ri and rdoc documentation in .gemrc.

    install: --no-rdoc --no-ri
    update: --no-rdoc --no-ri
    

    Then comes the Rails installation

    $ gem install rails --version 4.0.5

    I also had to install the following

    $ sudo apt-get install libxslt-dev libxml2-dev libsqlite3-dev
    

    Why the modification is needed?
    I actually didn’t pay heed to the instructions fully as I was whizzing through to get it over with ASAP😛 . And when I was doing the chapter 6, I found out that my setup was not done in the right way. Digging through my past (works) I found out an unintentionally missed point:

    Note: If your app is missing secret_token.rb and has secrets.yml instead, it probably means you installed Rails 4.1 by mistake. In this case, uninstall Rails using gem uninstall rails and then reinstall it by following the instructions in Section 1.2.2.5.

    So I had to go back and redo the setup properly.
    Every mistake has a price to pay…lol;)

     
  • Syed Muhammad Numan 5:55 am on November 6, 2013 Permalink |
    Tags: , , Skype,   

    Ubuntu: Skype installation 

    For some weird reason Skype doesn’t have a 64 bit version. Hence it poses all sorts of unwanted problems, so far, installing in Ubuntu 12.04.3 LTS code named precise-pangolin — a Linux variant!

    After searching for solutions in many places I found a solution at TRAVELLING LINUX . The steps for your reference are quoted here:

    • Edit /etc/apt/preferences: 

    $ sudo gedit /etc/apt/preferences

    • Add this 3 lines code:

    Package: *
    Pin: release a=precise*
    Pin-Priority: 2012

    • Do dist-upgrade:

    $ sudo apt-get dist-upgrade

    • Install ia32-libs-multiarch and/or ia32-libs:

    $ sudo apt-get install ia32-libs-multiarch

    • Delete /etc/apt/preferences, after you finished updating:

    $ rm /etc/apt/preferences

    • Other solution that work too:

    $ sudo apt-get install librtmp0/precise

    Hope this helps installing Skype!

     
  • Syed Muhammad Numan 12:32 pm on June 10, 2010 Permalink |
    Tags: , screen blinking   

    Why Chrome blinks after installing HP Softwares? and throws the following ? 

    Product
    Google Chrome

    Problem
    Stopped working

    Date
    10/06/2010 17:56

    Status
    Not Reported

    Problem signature
    Problem Event Name: APPCRASH
    Application Name: chrome.exe
    Application Version: 0.0.0.0
    Application Timestamp: 4bd40a55
    Fault Module Name: ntdll.dll
    Fault Module Version: 6.0.6002.18005
    Fault Module Timestamp: 49e03824
    Exception Code: c0000005
    Exception Offset: 0001e562
    OS Version: 6.0.6002.2.2.0.256.6
    Locale ID: 2057
    Additional Information 1: 40d4
    Additional Information 2: 4062ad41ec8067256aa4c5e2b56d3c79
    Additional Information 3: 40d4
    Additional Information 4: 4062ad41ec8067256aa4c5e2b56d3c79

    Files that help describe the problem
    Version.txt
    AppCompat.txt
    memory.hdmp
    minidump.mdmp

     
  • Syed Muhammad Numan 7:27 am on January 6, 2010 Permalink |
    Tags: regedit, Upper-Lower-Filters, , x64   

    Vista on my HP Compaq 6710b doesn’t recognize inserted CD/DVD 

    I am running a 64 bit Vista on my Compaq 6710b computer. It was running perfectly fine. Lately, one day it started refusing to read my cd/dvds that I insert in the drive ( my one is D: ).

    As usual, by ‘googling’ I found the following helps:

    Deleting the UpperFilters and LowerFilters as mentioned in Microsoft Support kb-929461 didn’t help the drives, rather created more problems of totally eliminating the drives from the face of the explorer window😦

    Nevertheless,even with the other helps above, I haven’t got the solution to my problem yet! Help me, if anyone can. please!

     
c
Compose new post
j
Next post/Next comment
k
Previous post/Previous comment
r
Reply
e
Edit
o
Show/Hide comments
t
Go to top
l
Go to login
h
Show/Hide help
shift + esc
Cancel
Follow

Get every new post delivered to your Inbox.

Join 737 other followers