Results 1 to 5 of 5
  1. #1
    BorisGomel is offline Competent Performer
    Windows Vista Access 2003
    Join Date
    Apr 2011
    Posts
    101

    Transfer Access into Excel problem

    Hi ,

    I hope you will help me with this samll problem .



    I am trying to export query off Access into Excel spreadsheet and I am using this code below:

    DimstDocName AsString
    DimtheFilePath AsString
    stDocName = "Mediation4"
    DoCmd.OpenQuery stDocName

    MsgBox "Look on your desktop for the report."

    theFilePath = " Y:\My Documents\UpdateChecks\Checks”
    theFilePath = theFilePath & stDocName & " "
    DoCmd.TransferSpreadsheet acExport, 10, reportName, theFilePath, True

    EndSub

    Where
    Mediation4 is name of query
    Y:\My Documents\UpdateChecks\Checks-directory where is file xsl is located (Chekcs in this case)
    The access debugs this by :" A value you eneterd for the speadsheettype argument is invalid".

    The code is in the click event of command box

    I am trying to fugure it out but so far got no success.

    Thank you in advance for advice how to fix it .

    The Best Regards.

  2. #2
    alansidman's Avatar
    alansidman is offline VIP
    Windows 7 32bit Access 2007
    Join Date
    Apr 2010
    Location
    Steamboat Springs
    Posts
    2,529
    Change your docmd line to read

    DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, reportName, theFilePath, True

    The acSpreadsheetTypeExcel9 is for Excel 2002.
    The acSpreadsheetTypeExcel10 is for Excel 2003
    The acSpreadsheetTypeExcel12 is for Excel 2007

    Alan

  3. #3
    BorisGomel is offline Competent Performer
    Windows Vista Access 2003
    Join Date
    Apr 2011
    Posts
    101

    Transfer Access into Excel problem

    Good Aftetnoon Alansidman,

    I insert your code and it works prefectly .

    Thank you sir ,

    Will mark as solved .

    Sir , just one small though if you give me some hint .

    The transferiinh Access Query into the Excel spreadheet is working fine , but it would be fine if the spreadsheet opens up once the transfer completed via Vb code in the same command button .I would not think about it , but when you helped me achived this , may be this small step would not be hard to help me with this

    Thank you for your time sir .

    Really appreacite your help and time.

  4. #4
    alansidman's Avatar
    alansidman is offline VIP
    Windows 7 32bit Access 2007
    Join Date
    Apr 2010
    Location
    Steamboat Springs
    Posts
    2,529
    Add the following code to your current code to open the spreadsheet. change the path and file name as appropriate.

    Code:
    Dim xlTmp As Excel.Application
    Set xlTmp = New Excel.Application
    xlTmp.Workbooks.Open "C:\Excel1.xls"
    xlTmp.Visible = True
    Alan

  5. #5
    BorisGomel is offline Competent Performer
    Windows Vista Access 2003
    Join Date
    Apr 2011
    Posts
    101

    Transfer Access into Excel

    Thank you very much !!!

    It works!!

    Thank you again,

    The Best Regards.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Problem with Excel import
    By itsmemike in forum Import/Export Data
    Replies: 3
    Last Post: 04-04-2011, 09:25 PM
  2. Link Excel to Access problem
    By gg80 in forum Access
    Replies: 1
    Last Post: 02-22-2011, 09:35 AM
  3. Transfer data to excel
    By John Southern in forum Import/Export Data
    Replies: 5
    Last Post: 06-11-2010, 09:26 AM
  4. Replies: 1
    Last Post: 08-31-2009, 10:24 AM
  5. excel to access problem
    By sahi0002 in forum Import/Export Data
    Replies: 0
    Last Post: 03-08-2009, 11:40 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums