Reputation: 87
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
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?
Upvotes: 0
Views: 377