- Public Sub ExportReportToWord()
- Dim wdApp As Object
- Dim wdDoc As Object
- Dim rtfPath As String
- Dim docxPath As String
- rtfPath = "C:\Ugovori\Ugovor.rtf"
- docxPath = "C:\Ugovori\Ugovor.docx"
- ' Exportuj Access report kao RTF
- DoCmd.OutputTo acOutputReport, "rptUgovor", acFormatRTF, rtfPath, False
- ' Otvori u Wordu i sacuvaj kao DOCX
- Set wdApp = CreateObject("Word.Application")
- Set wdDoc = wdApp.Documents.Open(rtfPath)
- wdDoc.SaveAs2 docxPath, FileFormat:=16 ' 16 = wdFormatDocumentDefault (docx)
- wdDoc.Close False
- wdApp.Quit
- Set wdDoc = Nothing
- Set wdApp = Nothing
- MsgBox "Izvezeno kao DOCX u: " & docxPath
- End Sub