+ Reply to Thread
Results 1 to 2 of 2

DoCmd.TransferSpreadsheet-Range and Filename problem

  1. #1
    Registered User
    Join Date
    01-19-2007
    Posts
    5

    DoCmd.TransferSpreadsheet-Range and Filename problem

    Hi:
    When using the tranferSpreadsheet method to import a range from excel into access, is there a way to change the filename and range dinamically. For example: instead of transfering range A1:A24 when I only have data from A1:A10, And instead of hardcoding the filename maybe using the currentProject.path. (Access file and excel file reside in the same folder)
    I have used something like this:

    dim rangeAddress
    RangeAddress=Cells(1,1).currentRegion

    DoCmd.TransferSpreadsheet transfertype:=acImport, _
    spreadsheettype:=acspreadsheettypeexcel8, _
    tablename:="AverageWeightFromExcel", _
    filename:="CurrentProject.path\WeightData.xls", _
    hasfieldnames:=True, _
    Range:="forecast!" & RangeAddress.Address

    But crashes when trying to use the range address and filename. Any help is appreciated.

  2. #2
    Forum Contributor
    Join Date
    03-13-2005
    Posts
    6,195
    Quote Originally Posted by mazatlanmexico
    Hi:
    When using the tranferSpreadsheet method to import a range from excel into access, is there a way to change the filename and range dinamically. For example: instead of transfering range A1:A24 when I only have data from A1:A10, And instead of hardcoding the filename maybe using the currentProject.path. (Access file and excel file reside in the same folder)
    I have used something like this:

    dim rangeAddress
    RangeAddress=Cells(1,1).currentRegion

    DoCmd.TransferSpreadsheet transfertype:=acImport, _
    spreadsheettype:=acspreadsheettypeexcel8, _
    tablename:="AverageWeightFromExcel", _
    filename:="CurrentProject.path\WeightData.xls", _
    hasfieldnames:=True, _
    Range:="forecast!" & RangeAddress.Address

    But crashes when trying to use the range address and filename. Any help is appreciated.
    Hi,

    the site http://www.mvps.org/access/general/gen0008.htm may help you, but the DoCmd is an Access item, this is an Excel forum and thus Access commands are not covered here.

    hth
    ---
    Si fractum non sit, noli id reficere.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1