Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 123
Default Unprotect workbook and merge


Hi,

I got the code from http://www.rondebruin.nl/

Sub CombineAll()
Dim FilesToOpen
Dim x As Integer

On Error GoTo ErrHandler
Application.ScreenUpdating = False

FilesToOpen = Application.GetOpenFilename _
(filefilter:="Microsoft Excel Files (*.xls), *.xls", _
MultiSelect:=True, Title:="Files to Merge")

If TypeName(FilesToOpen) = "Boolean" Then
MsgBox "No Files were selected"
GoTo ExitHandler
End If

x = 1
While x <= UBound(FilesToOpen)
Workbooks.Open Filename:=FilesToOpen(x)

Sheets().Move After:=ThisWorkbook.Sheets _
(ThisWorkbook.Sheets.Count)
x = x + 1
Wend


ExitHandler:
Application.ScreenUpdating = True
Sheets("start").Select

Exit Sub

ErrHandler:
MsgBox Err.Description
Resume ExitHandler
End Sub

This is excellent code and works fine... But the files which i am trying to
merge are protected. The workbook is protected in all files. How do i solve
this...

I tried...

Workbooks.Open Filename:=FilesToOpen(x), WriteResPassword:="password"
Workbooks.Open Filename:=FilesToOpen(x), Password:="password"

please help...
Thx!

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default Unprotect workbook and merge


Try..

Workbooks.Open Filename:="c:\filename.xls", _
Password:="password", WriteResPassword:="password"

If this post helps click Yes
---------------
Jacob Skaria


"Boss" wrote:

Hi,

I got the code from http://www.rondebruin.nl/

Sub CombineAll()
Dim FilesToOpen
Dim x As Integer

On Error GoTo ErrHandler
Application.ScreenUpdating = False

FilesToOpen = Application.GetOpenFilename _
(filefilter:="Microsoft Excel Files (*.xls), *.xls", _
MultiSelect:=True, Title:="Files to Merge")

If TypeName(FilesToOpen) = "Boolean" Then
MsgBox "No Files were selected"
GoTo ExitHandler
End If

x = 1
While x <= UBound(FilesToOpen)
Workbooks.Open Filename:=FilesToOpen(x)

Sheets().Move After:=ThisWorkbook.Sheets _
(ThisWorkbook.Sheets.Count)
x = x + 1
Wend


ExitHandler:
Application.ScreenUpdating = True
Sheets("start").Select

Exit Sub

ErrHandler:
MsgBox Err.Description
Resume ExitHandler
End Sub

This is excellent code and works fine... But the files which i am trying to
merge are protected. The workbook is protected in all files. How do i solve
this...

I tried...

Workbooks.Open Filename:=FilesToOpen(x), WriteResPassword:="password"
Workbooks.Open Filename:=FilesToOpen(x), Password:="password"

please help...
Thx!

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 123
Default Unprotect workbook and merge


This does not work, I tried it before...
I need to unprotect the workbook...

Thx!
"Jacob Skaria" wrote:

Try..

Workbooks.Open Filename:="c:\filename.xls", _
Password:="password", WriteResPassword:="password"

If this post helps click Yes
---------------
Jacob Skaria


"Boss" wrote:

Hi,

I got the code from http://www.rondebruin.nl/

Sub CombineAll()
Dim FilesToOpen
Dim x As Integer

On Error GoTo ErrHandler
Application.ScreenUpdating = False

FilesToOpen = Application.GetOpenFilename _
(filefilter:="Microsoft Excel Files (*.xls), *.xls", _
MultiSelect:=True, Title:="Files to Merge")

If TypeName(FilesToOpen) = "Boolean" Then
MsgBox "No Files were selected"
GoTo ExitHandler
End If

x = 1
While x <= UBound(FilesToOpen)
Workbooks.Open Filename:=FilesToOpen(x)

Sheets().Move After:=ThisWorkbook.Sheets _
(ThisWorkbook.Sheets.Count)
x = x + 1
Wend


ExitHandler:
Application.ScreenUpdating = True
Sheets("start").Select

Exit Sub

ErrHandler:
MsgBox Err.Description
Resume ExitHandler
End Sub

This is excellent code and works fine... But the files which i am trying to
merge are protected. The workbook is protected in all files. How do i solve
this...

I tried...

Workbooks.Open Filename:=FilesToOpen(x), WriteResPassword:="password"
Workbooks.Open Filename:=FilesToOpen(x), Password:="password"

please help...
Thx!

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 123
Default Unprotect workbook and merge


This does not work... I need to unprotect the workbook... Thx!

"Jacob Skaria" wrote:

Try..

Workbooks.Open Filename:="c:\filename.xls", _
Password:="password", WriteResPassword:="password"

If this post helps click Yes
---------------
Jacob Skaria


"Boss" wrote:

Hi,

I got the code from http://www.rondebruin.nl/

Sub CombineAll()
Dim FilesToOpen
Dim x As Integer

On Error GoTo ErrHandler
Application.ScreenUpdating = False

FilesToOpen = Application.GetOpenFilename _
(filefilter:="Microsoft Excel Files (*.xls), *.xls", _
MultiSelect:=True, Title:="Files to Merge")

If TypeName(FilesToOpen) = "Boolean" Then
MsgBox "No Files were selected"
GoTo ExitHandler
End If

x = 1
While x <= UBound(FilesToOpen)
Workbooks.Open Filename:=FilesToOpen(x)

Sheets().Move After:=ThisWorkbook.Sheets _
(ThisWorkbook.Sheets.Count)
x = x + 1
Wend


ExitHandler:
Application.ScreenUpdating = True
Sheets("start").Select

Exit Sub

ErrHandler:
MsgBox Err.Description
Resume ExitHandler
End Sub

This is excellent code and works fine... But the files which i am trying to
merge are protected. The workbook is protected in all files. How do i solve
this...

I tried...

Workbooks.Open Filename:=FilesToOpen(x), WriteResPassword:="password"
Workbooks.Open Filename:=FilesToOpen(x), Password:="password"

please help...
Thx!

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 123
Default Unprotect workbook and merge

I got it...

ActiveWorkbook.Unprotect Password:="password"

thx!

"Jacob Skaria" wrote:

Try..

Workbooks.Open Filename:="c:\filename.xls", _
Password:="password", WriteResPassword:="password"

If this post helps click Yes
---------------
Jacob Skaria


"Boss" wrote:

Hi,

I got the code from http://www.rondebruin.nl/

Sub CombineAll()
Dim FilesToOpen
Dim x As Integer

On Error GoTo ErrHandler
Application.ScreenUpdating = False

FilesToOpen = Application.GetOpenFilename _
(filefilter:="Microsoft Excel Files (*.xls), *.xls", _
MultiSelect:=True, Title:="Files to Merge")

If TypeName(FilesToOpen) = "Boolean" Then
MsgBox "No Files were selected"
GoTo ExitHandler
End If

x = 1
While x <= UBound(FilesToOpen)
Workbooks.Open Filename:=FilesToOpen(x)

Sheets().Move After:=ThisWorkbook.Sheets _
(ThisWorkbook.Sheets.Count)
x = x + 1
Wend


ExitHandler:
Application.ScreenUpdating = True
Sheets("start").Select

Exit Sub

ErrHandler:
MsgBox Err.Description
Resume ExitHandler
End Sub

This is excellent code and works fine... But the files which i am trying to
merge are protected. The workbook is protected in all files. How do i solve
this...

I tried...

Workbooks.Open Filename:=FilesToOpen(x), WriteResPassword:="password"
Workbooks.Open Filename:=FilesToOpen(x), Password:="password"

please help...
Thx!



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default Unprotect workbook and merge

Hi

'To unprotect workbook try
ActiveWorkbook.Unprotect "password"

'If workbook is password protected (both passwords in one line)
Workbooks.Open Filename:="c:\filename.xls", _
Password:="password", WriteResPassword:="password"

If this post helps click Yes
---------------
Jacob Skaria


"Boss" wrote:

This does not work... I need to unprotect the workbook... Thx!

"Jacob Skaria" wrote:

Try..

Workbooks.Open Filename:="c:\filename.xls", _
Password:="password", WriteResPassword:="password"

If this post helps click Yes
---------------
Jacob Skaria


"Boss" wrote:

Hi,

I got the code from http://www.rondebruin.nl/

Sub CombineAll()
Dim FilesToOpen
Dim x As Integer

On Error GoTo ErrHandler
Application.ScreenUpdating = False

FilesToOpen = Application.GetOpenFilename _
(filefilter:="Microsoft Excel Files (*.xls), *.xls", _
MultiSelect:=True, Title:="Files to Merge")

If TypeName(FilesToOpen) = "Boolean" Then
MsgBox "No Files were selected"
GoTo ExitHandler
End If

x = 1
While x <= UBound(FilesToOpen)
Workbooks.Open Filename:=FilesToOpen(x)

Sheets().Move After:=ThisWorkbook.Sheets _
(ThisWorkbook.Sheets.Count)
x = x + 1
Wend


ExitHandler:
Application.ScreenUpdating = True
Sheets("start").Select

Exit Sub

ErrHandler:
MsgBox Err.Description
Resume ExitHandler
End Sub

This is excellent code and works fine... But the files which i am trying to
merge are protected. The workbook is protected in all files. How do i solve
this...

I tried...

Workbooks.Open Filename:=FilesToOpen(x), WriteResPassword:="password"
Workbooks.Open Filename:=FilesToOpen(x), Password:="password"

please help...
Thx!

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,069
Default Unprotect workbook and merge


This approach may solve the problem to unprotect the workbook.
Change "mypassword" for the correct password

Sub CombineAll()
Dim FilesToOpen As Variant
Dim WB As Workbook
Dim x As Integer
Dim passwrd As String

On Error GoTo ErrHandler


FilesToOpen = Application.GetOpenFilename _
(filefilter:="Microsoft Excel Files (*.xls), *.xls", _
MultiSelect:=True, Title:="Files to Merge")

If TypeName(FilesToOpen) = "Boolean" Then
MsgBox "No Files were selected"
GoTo ExitHandler
End If

With Application
.ScreenUpdating = False
.DisplayAlerts = False
End With

passwrd = "mypassword"
x = 1
While x <= UBound(FilesToOpen)
Set WB = Workbooks.Open(Filename:=FilesToOpen(x), Password:="passwrd")

WB.Password = "passwrd"

Sheets().Move After:=ThisWorkbook.Sheets _
(ThisWorkbook.Sheets.Count)
x = x + 1
Wend


ExitHandler:
With Application
.ScreenUpdating = True
.DisplayAlerts = True
End With

Sheets("start").Select

Exit Sub

ErrHandler:
MsgBox Err.Description
Resume ExitHandler
End Sub
--
jb


"Boss" wrote:

Hi,

I got the code from http://www.rondebruin.nl/

Sub CombineAll()
Dim FilesToOpen
Dim x As Integer

On Error GoTo ErrHandler
Application.ScreenUpdating = False

FilesToOpen = Application.GetOpenFilename _
(filefilter:="Microsoft Excel Files (*.xls), *.xls", _
MultiSelect:=True, Title:="Files to Merge")

If TypeName(FilesToOpen) = "Boolean" Then
MsgBox "No Files were selected"
GoTo ExitHandler
End If

x = 1
While x <= UBound(FilesToOpen)
Workbooks.Open Filename:=FilesToOpen(x)

Sheets().Move After:=ThisWorkbook.Sheets _
(ThisWorkbook.Sheets.Count)
x = x + 1
Wend


ExitHandler:
Application.ScreenUpdating = True
Sheets("start").Select

Exit Sub

ErrHandler:
MsgBox Err.Description
Resume ExitHandler
End Sub

This is excellent code and works fine... But the files which i am trying to
merge are protected. The workbook is protected in all files. How do i solve
this...

I tried...

Workbooks.Open Filename:=FilesToOpen(x), WriteResPassword:="password"
Workbooks.Open Filename:=FilesToOpen(x), Password:="password"

please help...
Thx!

  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,069
Default Unprotect workbook and merge


whoops - soory, typing error with workbook unprotect!

Sub CombineAll()
Dim FilesToOpen As Variant
Dim WB As Workbook
Dim x As Integer
Dim passwrd As String

On Error GoTo ErrHandler


FilesToOpen = Application.GetOpenFilename _
(filefilter:="Microsoft Excel Files (*.xls), *.xls", _
MultiSelect:=True, Title:="Files to Merge")

If TypeName(FilesToOpen) = "Boolean" Then
MsgBox "No Files were selected"
GoTo ExitHandler
End If

With Application
.ScreenUpdating = False
.DisplayAlerts = False
End With

passwrd = "mypasswrd"
x = 1
While x <= UBound(FilesToOpen)
Set WB = Workbooks.Open(Filename:=FilesToOpen(x), Password:="passwrd")

WB.Unprotect Password:="passwrd"

Sheets().Move After:=ThisWorkbook.Sheets _
(ThisWorkbook.Sheets.Count)
x = x + 1
Wend


ExitHandler:
With Application
.ScreenUpdating = True
.DisplayAlerts = True
End With

Sheets("start").Select

Exit Sub

ErrHandler:
MsgBox Err.Description
Resume ExitHandler
End Sub

--
jb


"john" wrote:

This approach may solve the problem to unprotect the workbook.
Change "mypassword" for the correct password

Sub CombineAll()
Dim FilesToOpen As Variant
Dim WB As Workbook
Dim x As Integer
Dim passwrd As String

On Error GoTo ErrHandler


FilesToOpen = Application.GetOpenFilename _
(filefilter:="Microsoft Excel Files (*.xls), *.xls", _
MultiSelect:=True, Title:="Files to Merge")

If TypeName(FilesToOpen) = "Boolean" Then
MsgBox "No Files were selected"
GoTo ExitHandler
End If

With Application
.ScreenUpdating = False
.DisplayAlerts = False
End With

passwrd = "mypassword"
x = 1
While x <= UBound(FilesToOpen)
Set WB = Workbooks.Open(Filename:=FilesToOpen(x), Password:="passwrd")

WB.Password = "passwrd"

Sheets().Move After:=ThisWorkbook.Sheets _
(ThisWorkbook.Sheets.Count)
x = x + 1
Wend


ExitHandler:
With Application
.ScreenUpdating = True
.DisplayAlerts = True
End With

Sheets("start").Select

Exit Sub

ErrHandler:
MsgBox Err.Description
Resume ExitHandler
End Sub
--
jb


"Boss" wrote:

Hi,

I got the code from http://www.rondebruin.nl/

Sub CombineAll()
Dim FilesToOpen
Dim x As Integer

On Error GoTo ErrHandler
Application.ScreenUpdating = False

FilesToOpen = Application.GetOpenFilename _
(filefilter:="Microsoft Excel Files (*.xls), *.xls", _
MultiSelect:=True, Title:="Files to Merge")

If TypeName(FilesToOpen) = "Boolean" Then
MsgBox "No Files were selected"
GoTo ExitHandler
End If

x = 1
While x <= UBound(FilesToOpen)
Workbooks.Open Filename:=FilesToOpen(x)

Sheets().Move After:=ThisWorkbook.Sheets _
(ThisWorkbook.Sheets.Count)
x = x + 1
Wend


ExitHandler:
Application.ScreenUpdating = True
Sheets("start").Select

Exit Sub

ErrHandler:
MsgBox Err.Description
Resume ExitHandler
End Sub

This is excellent code and works fine... But the files which i am trying to
merge are protected. The workbook is protected in all files. How do i solve
this...

I tried...

Workbooks.Open Filename:=FilesToOpen(x), WriteResPassword:="password"
Workbooks.Open Filename:=FilesToOpen(x), Password:="password"

please help...
Thx!

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Unprotect workbook Kim Excel Discussion (Misc queries) 3 October 2nd 08 07:49 PM
unprotect workbook Deb Excel Discussion (Misc queries) 2 February 9th 07 07:40 PM
Unprotect Workbook Kent Excel Discussion (Misc queries) 1 February 4th 05 01:07 AM
Unprotect workbook Jean-Paul De Winter Excel Programming 4 October 17th 04 09:00 AM
Unprotect a Workbook Milind Excel Programming 0 September 10th 03 10:59 PM


All times are GMT +1. The time now is 12:05 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"