[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

DoCmd.TransferSpreadsheet Function

Posted on 2011-03-06
3
Medium Priority
?
654 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 500 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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
Code that checks the QuickBooks schema table for non-updateable fields and then disables those controls on a form so users don't try to update them.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
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…

656 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