View Single Post
 
Old 11-26-2013, 11:01 PM
macropod's Avatar
macropod macropod is offline Windows 7 32bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,467
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

I suspect your basic issue is that you have unqualified sheet & workbook references (plus you're code is telling Excel to open an xlsm file whereas the one you provided for testing is an xlsx file). Try:
Code:
Sub Test()
Dim xlWkBk As Workbook
Set xlWkBk = Workbooks.Open(Filename:="c:\My Documents\Try this.xlsx", _
  Password:="one", WriteResPassword:="two", AddToMRU:=False)
With xlWkBk
  .SaveAs Filename:="C:\My Documents\New\Try this 1.xlsm", _
    FileFormat:=xlOpenXMLWorkbookMacroEnabled, CreateBackup:=False, AddToMRU:=False
  .Sheets("Sheet1").Unprotect Password:="Test"
End With
End Sub
Note that there is no need for the ChDir code.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote