0

所以这是交易。我想从我的 Excel 文件中导入一些信息,以便在 VBA 中与它们“玩耍”。问题是有一种特定的导入方法,我有点想将它用于一些对我根本不起作用的映射。

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

使用它后,我收到以下错误在此处输入图像描述

Imports MapPoint我的代码开头也有。从某种意义上说,程序不知道如何从 Excel 工作表中获取数据是否存在一些干扰?我还必须说,我很确定这条路径是正确的,因为如果我使用类似的东西

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)

我继续使用 sh.Range 遍历每个单元格,它可以正常工作。的确,在第一个通路中,我也想直接“选择”我感兴趣的单元格,以便在 MapPoint 中上传数据,但我仍然认为应该没有问题。有任何想法吗?

4

0 回答 0