?
Solved

DoCmd.TransferSpreadsheet Function

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

10 Questions to Ask when Buying Backup Software

Choosing the right backup solution for your organization can be a daunting task. To make the selection process easier, ask solution providers these 10 key questions.

Question has a verified solution.

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

In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses

764 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