Author | Topic: Create Microsoft Access Database with ActiveX | |
---|---|---|
César Calvo | Create Microsoft Access Database with ActiveX on Sat, 03 Aug 2013 09:48:37 +0200 Friends, Is is possible to create one mdb or accdb with activex and xbase program? Do you have one example ? I see for excel yes: ----------------------------------------------------------------------------------------------------------------- #include "activex.ch" #include "excel.ch" PROCEDURE main LOCAL oExcel, oBook, oSheet LOCAL cDir, nRow Create the "Excel.Application" object oExcel := CreateObject("Excel.Application") IF Empty( oExcel ) MsgBox( "Excel is not installed" ) RETURN ENDIF oExcel:DisplayAlerts := .T. oExcel:visible := .F. oBook := oExcel:workbooks:Add() oSheet := oBook:ActiveSheet oSheet:PageSetup:Orientation := xlLandscape Save workbook as ordinary excel file. //oBook:SaveAs(cDir+"\MyExcel.xls",xlWorkbookNormal) oSheet:Cells(1,1):Value := "CESAR" oSheet:Cells(1,2):Value := 1.5 oSheet:Cells(1,3):Value := 48.58 oBook:SaveAs("C:\MyExcel.xlsx",xlWorkbookDefault) Quit Excel oExcel:Quit() oExcel:Destroy() RETURN ----------------------------------------------------------------------------------------------------------------- Regards, César. | |
César Calvo | Re: Create Microsoft Access Database with ActiveX on Sun, 04 Aug 2013 12:04:47 +0200 Hello, I am testing with the source below but never is created the database. Could anybody help me? Thanks. ------------------------------------------------------------------------------- cFile := "C:\ALASKA\XPPW32\source\samples\activex\msexcel\PRUEBA.accdb" IF FExists("D:\PRUEBA.accdb") FErase("D:\PRUEBA.accdb") ENDIF oDBF := CreateObject("Access.Application") or oDBF := CreateObject("ADOX.Catalog") IF Empty( oDBF ) MsgBox( "MS Access is not installed" ) RETURN ENDIF cFile := "D:\PRUEBA.accdb" cCon := "Provider=Microsoft.ACE.OLEDB.12.0;" cCon += "User ID=Admin;" cCon += "Data Source=" + cFile + ";" //cCon += "Jet OLEDB:Engine Type=4;" //cCon += "Persist Security Info=False;" //cCon += "Mode=Exclusive;" //cCon += 'Extended Properties="";' oDBF:Create(cCon) oDBF:Destroy() ------------------------------------------------------------------------------- "César Calvo" escribió en el mensaje de noticias:6c121a7a$3e3858de$d60e@news.alaska-software.com... Friends, Is is possible to create one mdb or accdb with activex and xbase program? Do you have one example ? I see for excel yes: ----------------------------------------------------------------------------------------------------------------- #include "activex.ch" #include "excel.ch" PROCEDURE main LOCAL oExcel, oBook, oSheet LOCAL cDir, nRow Create the "Excel.Application" object oExcel := CreateObject("Excel.Application") IF Empty( oExcel ) MsgBox( "Excel is not installed" ) RETURN ENDIF oExcel:DisplayAlerts := .T. oExcel:visible := .F. oBook := oExcel:workbooks:Add() oSheet := oBook:ActiveSheet oSheet:PageSetup:Orientation := xlLandscape Save workbook as ordinary excel file. //oBook:SaveAs(cDir+"\MyExcel.xls",xlWorkbookNormal) oSheet:Cells(1,1):Value := "CESAR" oSheet:Cells(1,2):Value := 1.5 oSheet:Cells(1,3):Value := 48.58 oBook:SaveAs("C:\MyExcel.xlsx",xlWorkbookDefault) Quit Excel oExcel:Quit() oExcel:Destroy() RETURN ----------------------------------------------------------------------------------------------------------------- Regards, César. | |
César Calvo | Re: Create Microsoft Access Database with ActiveX on Mon, 05 Aug 2013 19:33:43 +0200 I found the solution and is easy: PROCEDURE MAIN LOCAL oAccess IF FExists("D:\PRUEBA.accdb") FErase("D:\PRUEBA.accdb") ENDIF Create the "Access.Application" object oAccess := CreateObject("Access.Application") IF Empty( oAccess ) MsgBox( "Access is not installed" ) RETURN ENDIF oAccess:NewCurrentDatabase("D:\PRUEBA.accdb") Quit Access oAccess:Quit() oAccess:Destroy() RETURN ------------------------------------------------------------------------------------------------------- "César Calvo" escribió en el mensaje de noticias:6c121a7a$3e3858de$d60e@news.alaska-software.com... Friends, Is is possible to create one mdb or accdb with activex and xbase program? Do you have one example ? I see for excel yes: ----------------------------------------------------------------------------------------------------------------- #include "activex.ch" #include "excel.ch" PROCEDURE main LOCAL oExcel, oBook, oSheet LOCAL cDir, nRow Create the "Excel.Application" object oExcel := CreateObject("Excel.Application") IF Empty( oExcel ) MsgBox( "Excel is not installed" ) RETURN ENDIF oExcel:DisplayAlerts := .T. oExcel:visible := .F. oBook := oExcel:workbooks:Add() oSheet := oBook:ActiveSheet oSheet:PageSetup:Orientation := xlLandscape Save workbook as ordinary excel file. //oBook:SaveAs(cDir+"\MyExcel.xls",xlWorkbookNormal) oSheet:Cells(1,1):Value := "CESAR" oSheet:Cells(1,2):Value := 1.5 oSheet:Cells(1,3):Value := 48.58 oBook:SaveAs("C:\MyExcel.xlsx",xlWorkbookDefault) Quit Excel oExcel:Quit() oExcel:Destroy() RETURN ----------------------------------------------------------------------------------------------------------------- Regards, César. |