Solved

DoCmd.TransferSpreadsheet Function

Posted on 2011-03-06
3
645 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
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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

It took me quite some time to sort out all the different properties of combo and list boxes available from Visual Basic at run-time. Not that the documentation is lacking: the help pages are quite thorough and well written. The problem was rather wh…
In the article entitled Working with Objects – Part 1 (http://www.experts-exchange.com/Microsoft/Development/MS_Access/A_4942-Working-with-Objects-Part-1.html), you learned the basics of working with objects, properties, methods, and events. In Work…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…

707 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now