Tuesday, 2 October 2012

Error : The project currently contains references to more than one version of Microsoft.Vbe.Interop

I get this error message when ever I oped a VB.Net project from all the Visual Studio versions.

This is because you have a different version of office installed in your PC. To get rid of this error and compile your project successfully please follow this.

You need to locate the correct version of office dll files and place them in the project bin folder and add these references to you project.

i.e. in my case

Microsoft.Office.Interop.Excel.dll           (11.0.0.0)
Office.dll         (11.0.0.0)

It was confused because my computer had the office 2010 installed (I checked this with other computers had different office version as well)

Best Luck
Siraj




Tuesday, 3 April 2012

XML XSD in EXCEL

http://office.microsoft.com/en-us/excel-help/overview-of-xml-in-excel-HA010206396.aspx

Monday, 26 March 2012

Friday, 23 March 2012

VBA Scripting.Dictionary

This how to use VBA Scripting.Dictionary

Dim BioSolveParameterFieldList As Scripting.Dictionary
Set ParameterFieldList = New Scripting.Dictionary
ParameterFieldList.Add "Param1", "F5"
ParameterFieldList.Add "Param2", "F6"

ParameterItems = ParameterFieldList.Items
ParameterKeys = ParameterFieldList.Keys

For i = 0 To BioSolveParameterFieldList.Count - 1
MsgBox (ParameterItems(i)) & " " & ParameterKeys(i)
MsgBox ParameterFieldList("MyKey")
Next



Sub DictExample1()
Dim dict As Dictionary
Dim v As Variant
    'Create the dictionary         
    Set dict = New Dictionary
   'Add some (key, value) pairs
    dict.Add "John", 34
    dict.Add "Jane", 42
    dict.Add "Ted", 402
    'How many items do we have?
    Debug.Print "Number of items stored: " & dict.Count
    'We can retrieve an item based on the key
    Debug.Print "Ted is " & dict.Item("Ted") & " years old"

   'We can test whether an item exists
    Debug.Print "We have Jane's age: " & dict.Exists("Jane")
    Debug.Print "We have Zak's age " & dict.Exists("Zak")
    'We can update a value by replacing it
   dict.Item("Ted") = dict.Item("Ted") / 10
    Debug.Print "Ted's real age is: " & dict.Item("Ted")
   'We can add more items
    dict.Add "Carla", 23
   'And we can iterate through the complete dictionary
    For Each v In dict.Keys
        Debug.Print "Name: " & v & "Age: "; dict.Item(v)
    Next
End Sub