![]() |
|
#1
|
||||
|
||||
![]()
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
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#2
|
|||
|
|||
![]() Quote:
![]() |
#3
|
||||
|
||||
![]()
Aha! Good call, macropod. Funky, this is why I've gotten into the habit of qualifying almost everything in VBA; there are just too many ways to lose track of what the default may be. Besides, a lot of programs I write work with multiple worksheets, workbooks etc. So I find it a useful habit to just define a variable for each object I'll be working with, something like this:
Code:
Set woIp = ThisWorkbook Const wnOp = "TLXI.xlsx" If Not Exists(Workbooks,wnOp) Then Abend "Can't find workbook " & wnOp Set woOp = Workbooks(wnop) Set soIp = woIp.Worksheets("Misc") woOp.Worksheets.Add set soOp = ActiveWorksheet soOp.Name = "New" |
![]() |
Tags |
password, remove password |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Password protected file no longer offers password dialog on Open | htaylor | Word | 0 | 10-15-2013 12:35 PM |
![]() |
samkiewhock | Excel | 1 | 09-06-2012 03:34 AM |
![]() |
pask | Outlook | 5 | 03-16-2012 08:43 AM |
![]() |
HantsDave | Word VBA | 9 | 03-08-2012 11:57 AM |
![]() |
cure4glass | Word | 1 | 02-17-2012 07:19 PM |