Results 1 to 4 of 4
  1. #1
    Ruegen's Avatar
    Ruegen is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2013
    Location
    Australia
    Posts
    1,496

    Export report as RTF but save file name as .doc

    I am using:

    Code:
    Dim strSql As String
    Dim dlgOpen As FileDialog
        Set dlgOpen = Application.FileDialog(msoFileDialogSaveAs)
        With dlgOpen
            .InitialFileName = Me.CboArea.Column(1) & ".doc"
            .Show
            
        End With
        
        
    strSql = "SELECT tblShows.ID, tblShows.ShowName, tblShows.Blurb, tblShowTour.DateTouringFrom, tblShowTour.DateTouringUntil, tblShowTour.TypeID, tblShowTour.AreasID, tblShowTour.YearID " & vbCrLf & _
    "FROM tblYear INNER JOIN (tblType INNER JOIN (tblTerms INNER JOIN (tblStates INNER JOIN (tblShows INNER JOIN (tblAreas INNER JOIN tblShowTour ON tblAreas.ID = tblShowTour.AreasID) ON tblShows.ID = tblShowTour.ShowsID) ON tblStates.ID = tblAreas.StatesID) ON tblTerms.ID = tblShowTour.TermsID) ON tblType.ID = tblShowTour.TypeID) ON tblYear.ID = tblShowTour.YearID " & vbCrLf & _
    "WHERE (((tblShowTour.TypeID)=[Forms]![frmOrganiser]![CboType]) AND ((tblShowTour.AreasID)=[forms]![frmOrganiser]![CboArea]) AND ((tblShowTour.YearID)=[forms]![frmOrganiser]![CboYear]));"
    
    
        DoCmd.OpenReport "rptPrintOut", acViewPreview, strSql, "", acHidden
        DoCmd.SelectObject acReport, "rptPrintOut"
        DoCmd.OutputTo acOutputReport, "rptPrintOut", acFormatRTF, dlgOpen & Me.CboArea.Column(1) & ".doc", False
        DoCmd.Close acReport, "rptPrintOut"

    I need help with the file name - it does give me the right save file name however I get FileDialog(msoFileDialogSaveAs) in front of my file name... any help of course appreciated

  2. #2
    Ruegen's Avatar
    Ruegen is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2013
    Location
    Australia
    Posts
    1,496
    *Makes a shrine to the June7 god*

  3. #3
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,527
    Access doesnt save as Word docs....you'd have to save the RTF then open Word and convert it...

    Code:
    Sub SaveAsWordDoc(ByVal pvFile)
    Dim wrd As Word.Application
    Dim vNewfile
    Set wrd = CreateObject("word.Application")
    wrd.Documents.Open pvFile
    wrd.Visible = True
    vNewfile = pvFile & ".doc"
    wrd.Documents(1).SaveAs vNewfile, 0
    wrd.Quit
    Set wrd = Nothing
    End Sub
    DONT forget the Word REFERENCE in VBE..
    Click image for larger version. 

Name:	references.png 
Views:	10 
Size:	14.1 KB 
ID:	16689

  4. #4
    Ruegen's Avatar
    Ruegen is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2013
    Location
    Australia
    Posts
    1,496
    Quote Originally Posted by ranman256 View Post
    Access doesnt save as Word docs....you'd have to save the RTF then open Word and convert it...

    Code:
    Sub SaveAsWordDoc(ByVal pvFile)
    Dim wrd As Word.Application
    Dim vNewfile
    Set wrd = CreateObject("word.Application")
    wrd.Documents.Open pvFile
    wrd.Visible = True
    vNewfile = pvFile & ".doc"
    wrd.Documents(1).SaveAs vNewfile, 0
    wrd.Quit
    Set wrd = Nothing
    End Sub
    DONT forget the Word REFERENCE in VBE..
    Click image for larger version. 

Name:	references.png 
Views:	10 
Size:	14.1 KB 
ID:	16689
    I'm guessing this requires and opens Word - neither of which I want due to staff running run time.

    I'd prefer to have good file naming using the code I supplied above...

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

Similar Threads

  1. Replies: 5
    Last Post: 02-03-2014, 03:06 AM
  2. Replies: 13
    Last Post: 12-12-2013, 07:22 PM
  3. Save a report file without preview
    By alex__ice in forum Reports
    Replies: 2
    Last Post: 04-16-2013, 08:13 AM
  4. Replies: 1
    Last Post: 06-09-2011, 11:10 PM
  5. Print,save as and export option in report?
    By sunny in forum Reports
    Replies: 1
    Last Post: 07-27-2010, 09:55 AM

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