Access TransferSpreadsheet命令选择自定义范围

时间:2013-11-14 19:59:18

标签: vba ms-access import range

所以只是为了我的背景。没有访问培训,我必须以某种方式设置条形码,导入和创建身份证(哦和通过访问更新莲花笔记联系人!(仍然不知道我将如何使这一个工作))很抱歉,如果我的问题似乎......非常愚蠢。

无论如何,我正在尝试将excel表格中的自定义列范围重点放到表格中。这种格式永远不会改变,并且是每月生成的,我只需要弄清楚如何为我想要的列设置范围。

这是我的代码:

  Private Sub Command143_Click()
Box1 = MsgBox("Importing information CANNOT be undone, are you sure you want to continue?(BE SURE TO BACK UP THE ORIGINAL TABLE FIRST!!!)", vbOKCancel, "Warning!!!")
If Box1 = vbOK Then
DoCmd.TransferSpreadsheet acImport, 10, _
    "blarg", Me.Text138, True, "(range goes here)"
End If
End Sub

到目前为止,一切都很好,只需要选择自定义范围,但我似乎无法使synthax正确。任何想法?

1 个答案:

答案 0 :(得分:1)

这对Access 2007有用:

Private Sub Command143_Click()
  Dim Box1
  Box1 = MsgBox("Importing information CANNOT be undone, are you sure you want to continue?(BE SURE TO BACK UP THE ORIGINAL TABLE FIRST!!!)", vbOKCancel, "Warning!!!")
  If Box1 = vbOK Then
    DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel12Xml, _
      "blarg", Me.Text138, True, "B2:C5"
  End If
End Sub

Excel文档,范围B2:C5的第一行将用作结果表的字段名称:

enter image description here ====>

enter image description here