MS Access VBA how to open Excel File

Sometimes you need to open excel file from your ms access form, here is the code you may try..

Option Compare Database
Option Explicit

Sub OpenSpecific_xlFile()

    Dim oXL As Object
    Dim oExcel As Object
    Dim sFullPath As String
    Dim sPath As String
   
       
'   Buat Excel instance
    Set oXL = CreateObject("Excel.Application")
   
   
'  Handling control Property
    On Error Resume Next
    oXL.UserControl = True
    On Error GoTo 0
   
       
'   Full path file yang akan dibuka
    On Error GoTo ErrHandle
    sFullPath = CurrentProject.Path & "FILECONTOH_INVOICE.xlsm"
   
   
'   buka file
    With oXL
        .Visible = True
        .Workbooks.Open (sFullPath)
    End With
   
   
ErrExit:
    Set oXL = Nothing
    Exit Sub
   
ErrHandle:
    oXL.Visible = False
    MsgBox Err.Description
    GoTo ErrExit
End Sub

Thanks

Hery (Freelance IT Trainer 081223344506)

Hery Purnama – 081.223344.506 – inhousetrainer@yahoo.com.
Freelance IT Trainer, Trainer Excel VBA Macro, Trainer Sencha ExtJS, Trainer Google Map API, Trainer SPSS, Trainer MS Project, Trainer Primavera, Trainer Google Sktechup 3D, Trainer Android Phonegap, Trainer Oracle, Trainer SQL Server, Trainer MySQL, Trainer PHP Jquery Mobile , Trainer Java, Trainer HTML5 Javascript, Trainer SEO Internet Marketing, Trainer Project Management, Trainer SMS Gateway, Trainer CMS WordPress, ITIL, COBIT

Excel VBA activeworkbook refreshall WAIT until finished

Sometimes you need the delay or waiting excel VBA code till all the workbook refreshing methode is finished

For i = 1 To ActiveWorkbook.Connections.Count
    ActiveWorkbook.Connections(i).ODBCConnection.BackgroundQuery = False 'for odbc
    'ActiveWorkbook.Connections(i).OLEDBonnection.BackgroundQuery = False 'for oledb
    'MsgBox ActiveWorkbook.Connections(i).OLEDBConnection.BackgroundQuery
Next
    ActiveWorkbook.RefreshAll
   

Thanks,

Regards

Hery ( Freelance Excel VBA Trainer 081223344506)

Hery Purnama – 081.223344.506 – inhousetrainer@yahoo.com.
Freelance IT Trainer, Trainer Excel VBA Macro, Trainer Sencha ExtJS, Trainer Google Map API, Trainer SPSS, Trainer MS Project, Trainer Primavera, Trainer Google Sktechup 3D, Trainer Android Phonegap, Trainer Oracle, Trainer SQL Server, Trainer MySQL, Trainer PHP Jquery Mobile , Trainer Java, Trainer HTML5 Javascript, Trainer SEO Internet Marketing, Trainer Project Management, Trainer SMS Gateway, Trainer CMS WordPress, ITIL, COBIT

Freelance trainer excel vba macro , bandung jakarta

Hery Purnama 081223344505 , freelance inhouse excel vba macro, android phonegap, google map api, google sketchup 3d, php ajax jquery, project management, ms project, ms access, excel for accounting, ITIL , oracle dba, sql server, VB.net , asp.net, sms gateway, marketing strategy. Pengajar freelance inhouse berpengalaman 15 tahun and certified trainer

Call 081.223344.506 for invitation or goto http://freelance-it-trainer.blogspot.com

Hery Purnama – 081.223344.506 – inhousetrainer@yahoo.com.
Freelance IT Trainer, Trainer Excel VBA Macro, Trainer Sencha ExtJS, Trainer Google Map API, Trainer SPSS, Trainer MS Project, Trainer Primavera, Trainer Google Sktechup 3D, Trainer Android Phonegap, Trainer Oracle, Trainer SQL Server, Trainer MySQL, Trainer PHP Jquery Mobile , Trainer Java, Trainer HTML5 Javascript, Trainer SEO Internet Marketing, Trainer Project Management, Trainer SMS Gateway, Trainer CMS WordPress, ITIL, COBIT