Setting up your computer for first use

Instructions for a happier life.

Visual Studio (VS) is a commercial grade technology. It is very powerful, but also rather finicky. It requires special care for setting it up. Follow these instructions every time you start working on a new PC (e.g., when in a lab you choose a different seat).


Step 1: Close all related applications

  • Fully quit all open instances of Visual Studio, if any.
  • Make sure Excel is not running: Press Ctrl + Alt + Delete and select Task Manager, or Right‑click the taskbar and choose Task Manager. Look for any running Excel processes > right‑click each one and select End task.

  • Step 2: Configure Excel

  • Start Excel and open a new blank workbook.
  • Go to File → Options → Add‑ins → At the bottom, next to Manage: Excel Add‑ins → Go
    Uncheck all add‑ins, except those related to Visual Studio, VSTO, or VBA → OK
  • Go to File → Options → Add‑ins (again) → Next to Manage: COM Add‑ins → Go
    Uncheck all add‑ins, except those related to Visual Studio, VSTO, or VBA → OK
  • Go to File → Options → General → Check Optimize for compatibility
  • Go to File → Options → Trust Center → Trust Center Settings → Select Trusted Locations → Add new location
    Browse to: C:\Users\[yourUserID]\Desktop → Check “Subfolders of this location are also trusted” → OK (close all dialogs)
  • Quit Excel completely.

  • Step 3: Configure Visual Studio (VS)

  • Start VS, go to Tools → Options → Environment → General → Uncheck “Optimize rendering for screens with different pixel densities”
  • Restart VS
  • Create a new project. On top of the"create..." window, select Visual Basic, Windows, and Office.
    Pick a new VSTO Excel Workbook project from the list
    Location: Either accept the default or (recommended) use your Desktop. If you accept the default location: write it down. You will need to retrieve the folder later for submitting the homework. If you see an 'untrusted location' error, you will also need to add it later as a Trusted Location in Excel
  • Pick a project and solution name (can be the same - e.g., "H01")  → click Create, and a couple of OK
  • If you see Excel inside VS (you might need to scroll up and down), you are almost done done.
  • Click on ThisWorkbook.vb in the solution explorer>  view code and type:
    Imports System.ComponentModel
    Public Class ThisWorkbook
        Private Sub ThisWorkbook_Startup() Handles Me.Startup
            If LicenseManager.UsageMode = LicenseUsageMode.Designtime Then
                Exit Sub
            End If
        End Sub

        Private Sub ThisWorkbook_Shutdown() Handles Me.Shutdown
        End Sub
    End Class
  • Then go to Sheet1.vb code and type
    If LicenseManager.UsageMode = LicenseUsageMode.Designtime Then
                Exit Sub
            End If
    just under the line that reads:    Private Sub Sheet1_Startup() Handles Me.Startup

  • If Step 3 does not work

  • Check again that Excel is not running: Press Ctrl + Alt + Delete and select Task Manager, or Right‑click the taskbar and choose Task Manager. Look for any running Excel processes > right‑click each one and select End task.
  • Sometimes that is enough to make VS work.  Else, repeat Step 3.
  • In the top tab: Window → Reset windows layout → Expand the ExcelWorkbook → Click Sheet1.vb.  If you see Excel inside VS (you might need to forece a screen refresh in Excel by scrolling Excel up and down), you are done. Victory!

This what you should see if successful

A screenshot

If it still does not work

Repeat this procedure from the very top. Do to skip steps. If you fail after a couple of attempts of the full procedure: move to a different computer and repeat the process from the beginning. It can be frustrating but you will succeed (eventually)!