Link to home
Start Free TrialLog in
Avatar of fitaliano
fitalianoFlag for United States of America

asked on

Calling Excel functions from Access

I am trying to open and unprotect an excel from Access, I have the following code which opens the file but I am not able to unprotect once it is open.  Could you help me to fix it?  It would be fantastic if I could unprotect/protect without opening the file.

    Dim xlAp As Excel.Application
    Dim xlWB As Excel.Workbook
    Set xlApp = New Excel.Application
    With xlApp
         .Visible = True
         Set xlWB = .Workbooks.Open("C:\WFReports_CG.xls", , False)
         Set xlWB = .ThisWorkbook.UnProtect("101112131415161718191a1b1c")
    End With
Avatar of fitaliano
fitaliano
Flag of United States of America image

ASKER

I actually found the way to unprotect once open.  Could someone help me with unprotecting without opening the workbook?

    Dim xlAp As Excel.Application
    Dim xlWB As Excel.Workbook
    Set xlApp = New Excel.Application
    With xlApp
         .Visible = True
         Set xlWB = .Workbooks.Open("C:\WFReports_CG.xls", , False)
         .ActiveWorkbook.UnProtect ("101112131415161718191a1b1c")
    End With
ASKER CERTIFIED SOLUTION
Avatar of Patrick Matthews
Patrick Matthews
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial