open excel file from button on form access

Elhbeb

Registered User.
Local time
Yesterday, 22:24
Joined
Dec 13, 2012
Messages
10
Hi everyone, this is first post in this forum....
any way I have Database in access 2010 and linked file with excel and I have code for open excel file from button on form..

-------------------Start CODE-------------------------

Code:
Private Sub Command33_Click()

     '   Late Binding (Needs no reference set)
    Dim oXL As Object
    Dim oExcel As Object
    Dim sFullPath As String
    Dim sPath As String
     
     
     '   Create a new Excel instance
    Set oXL = CreateObject("Excel.Application")
        
     
     '   Full path of excel file to open
    On Error GoTo ErrHandle
    sFullPath = CurrentProject.Path & "\DataBaseExcelLink.xls"
     
     
     '   Open it
    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
-------------------End CODE-------------------------

my problem is..
I need protect file excel " any gays don't have open without access form with click button"

I'm Protect excel file with password but I don't know how open this from access vba without requested the password

sorry for any word incorrect my English is beginner.

Thanks....
 
Function Open(Filename As String, [UpdateLinks], [ReadOnly], [Format], [Password], [WriteResPassword], [IgnoreReadOnlyRecommended], [Origin], [Delimiter], [Editable], [Notify], [Converter], [AddToMru], [Local], [CorruptLoad]) As Workbook

In the actual file, I think you'll want to apply a password to open it then from the databsae, I think you'll want to set the read only parameter and send the password to open it.

In the file, you may also want to apply a write protect password.
 
Function Open(Filename As String, [UpdateLinks], [ReadOnly], [Format], [Password], [WriteResPassword], [IgnoreReadOnlyRecommended], [Origin], [Delimiter], [Editable], [Notify], [Converter], [AddToMru], [Local], [CorruptLoad]) As Workbook

In the actual file, I think you'll want to apply a password to open it then from the databsae, I think you'll want to set the read only parameter and send the password to open it.

In the file, you may also want to apply a write protect password.

Thanks for alert and reply.
I'm beginner in vba access, I don't understand where insert this code.
I import this code from internet this work very well with out Protect. where I can edit. my password is "1234"
 
I'm not sure if you're still working on this or not.

Your pasted code includes this line:
Code:
.Workbooks.Open (sFullPath)

Your new line would need to look something like this:
Code:
.workbooks.Open(sFullPath,, True,, [Password])

Of course, you would need to set a password on the actual Excel file.
 

Users who are viewing this thread

Back
Top Bottom