Hello
I have the two following code parts (the first gives me a FileDialog box for saving, the second does the transferspreadsheet part). Before I tried exporting using acSpreadsheetTypeExcel12 and xlsx, it worked fine. But when I try using acSpreadsheetTypeExcel12XML and save it to xlsm, it gives me an error 3027. Is it not possible using the below parts, to export to an xlsm macro-enabled workbook?
Code:Option Compare Database Public Function FilToSave() Dim FlDia As FileDialog Set FlDia = Application.FileDialog(msoFileDialogSaveAs) With FlDia .AllowMultiSelect = False .InitialFileName = "C:\" ' You can set outfile to a full path with a fictitious or real file name, and the dialog will open in that folder. .Title = "Navngiv filen med det ønskede navn" If .Show = True Then FilName = .SelectedItems(1) Else MsgBox "No file selected. Process cancelled" DoCmd.Hourglass False FilToSave = "Cancelled" Exit Function End If End With FilToSave = FilName & ".xlsm" End FunctionCode:Public Function Export2Queries() Dim savefile As String savefile = FilToSave If savefile <> "Cancelled" Then DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel12Xml, "Price", savefile, True DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel12Xml, "Unik", savefile, True DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel12Xml, "Fourbeholdning", savefile, True End If End Function


Reply With Quote


(pun intended
)
