Solved

DoCmd.TransferSpreadsheet Function

Posted on 2011-03-06
3
650 Views
Last Modified: 2012-06-27
I'd like the spreadsheet to open immediately for the user once they click this button, the same as happens using Docmd.OutputTo.  Is there a parameter I'm missing ??  See attached code.  You'll see I've replaced the Docmd.OutputTo with DoCmd.TransferSpreadsheet.  Ths is because a memo field gets truncated with the Docmd.OutputTo function if it's bigger than 255 characters, but works sweet using DoCmd.TransferSpreadsheet.   So if you can enlighten me on how to automatically open the spreadsheet I'd appreciate it greatly!  
Private Sub btnOpusRAMMFormat_Click()
    Dim strInput As Integer
    Dim strFileName As String
    Dim strText As String
    On Error Resume Next
    strInput = InputBox("Enter Status")
    Forms![FrmMisc]![txtStatus] = strInput
    strText = InputBox("Enter any text you might want this included in the file name, eg Nov2007.  DO NOT INCLUDE ANY BLANKS!!")
    strFileName = "M:\ThamesC0901\Reports\OpusRAMMExportStatus" & strInput & strText & ".xls"
    DoCmd.SetWarnings False
    DoCmd.OpenQuery "delOpusRammExport"
    DoCmd.OpenQuery "appOpusExport"
    DoCmd.OpenQuery "updOpusRammStep1"
    DoCmd.OpenQuery "updOpusRammStep2"
    DoCmd.OpenQuery "delOpusRammExportTemp"
    DoCmd.OpenQuery "appOpusExportTemp"
    
    DoCmd.TransferSpreadsheet acExport, , "OpusRAMMExportTemp", strFileName, , , True
   
    'DoCmd.OutputTo acOutputQuery, "qryOpusExportRAMMFormat", acFormatXLS, strFileName, True
    MsgBox "Finished. Check spreadsheet in M:\ThamesC0901\Reports\..."
    DoCmd.SetWarnings True

End Sub

Open in new window

0
Comment
Question by:KarenPRuskin
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 3

Accepted Solution

by:
JAMcDo earned 125 total points
ID: 35053305
Try adding this code after liine 22.  Modify as needed for your situation.

    Dim appxcel As Object
    Dim appexcel As Object
   
    Set appexcel = CreateObject("Excel.Application")

    Set appxcel = appexcel.Workbooks.Open(strFileName)
   
    appexcel.Visible = True

'Select Sheet1
    appexcel.Sheets("Sheet1").Select
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 35060442
You cannot open the spreadsheet automatically with Transfer spreadsheet
(See the help files on both Methods for more info)

0
 

Author Closing Comment

by:KarenPRuskin
ID: 35060454
Perfect solution!  Thanks so much, I'll use it again and again.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
AutoNumbers should increment automatically, without duplicates.  But sometimes something goes wrong, and the next AutoNumber value is a duplicate.  This article shows how to recover from this problem.
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

696 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question