0

So here's the deal. I want to import some information from my Excel file to "play around" with them in VBA. The problem is that there is a certain method of import, which I kinda want to use for some Mapping that will simply not work for me.

Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
    Dim oApp As New MapPoint.Application
    oApp.Visible = True
    oApp.UserControl = True
    Dim oMap As MapPoint.Map
    oMap = oApp.NewMap()
    oMap.MapStyle = GeoMapStyle.geoMapStyleData
    Dim wtf As String
    wtf = "C:\users\admin\Desktop\Clienti.xlsx!Sheet1!B1:C8"
    Dim ods As MapPoint.DataSet
    ods = oApp.ActiveMap.DataSets.ImportData(wtf, , GeoCountry.geoCountryRomania, GeoDelimiter.geoDelimiterDefault, 0)
    ods.Symbol = 6
    ods.ZoomTo()
    MsgBox("Closing MapPoint")
    Try
        oApp.Quit()
    Catch ex As Exception
        MsgBox("Already closed")
    End Try
End Sub

After I use this, I get the following error enter image description here

I also have Imports MapPoint at the beginning of my code. Is there some interference in a sense that the program does not know how to get the data from the Excel worksheet? I must also say that I am quite certain the pathway is correct because if I for example use something like

Dim eapp as New Excel.Application
Dim wbk As Excel.Workbook = eapp.Workbooks.Open("C:\users\admin\Desktop\Clienti.xlsx")
Dim sh As Excel.Worksheet = wbk.Sheets(1)

and I continue to go through every cell with sh.Range, it works without a problem. It is true that in the first pathway, I also want to "select" the cells I am interested in directly, so that the data can be uploaded in MapPoint, but I still think it should not be an issue. Any ideas?

Ciuboss
  • 67
  • 7
  • 2
    The code you present is VB.Net and not VBA. Please note that VBA is not is not is not is not VB.Net. VB.Net cannot be used in Excel, you'd have to be working with a comAddin or some such like. – freeflow Dec 12 '20 at 22:23
  • Obscure problem, but [this post](https://social.msdn.microsoft.com/Forums/en-US/e8d39dbe-6e67-40f3-8baf-a0dee3fac24f/new-to-mappoint?forum=vemapcontroldev) makes it fairly evident that you can't skip parameters. – Hans Passant Dec 12 '20 at 23:53

0 Answers0