merge xls and xlsx work books protected and hidden sheet

Freshbambam

New Member
Joined
Apr 27, 2012
Messages
12
Good afternoon,

BACKGROUND:-

I am using a bastardisation of Merge data from all workbooks in a folder (1)</SPAN></SPAN>
from Ron de Bruin, link:-

http://msdn.microsoft.com/en-us/library/cc837974.aspx</SPAN></SPAN>

</SPAN>

The difference is that I have to extract data from protected books on a hidden sheet (all books are unlocked with the same password and the hidden sheet name is the same).

I have added the following code:-

HD_Array = Array("file_name", "Project", "Name", "Task", "Amount")
Range("A1:D1").Value = HD_Array
'
Start at row 2
rnum = 2
' Loop through all files in the myFiles array.
If FNum > 0 Then
For FNum = LBound(MyFiles) To UBound(MyFiles)
Set mybook = Nothing
On Error Resume Next
Set mybook = Workbooks.Open(MyPath & MyFiles(FNum), _
Password:="pass12", WriteResPassword:="pass12", UpdateLinks:=0)

Sheets("data_1").Visible = True '
This is the named sheet.
'
Change here if other sheet required.
On Error GoTo 0
If Not mybook Is Nothing Then
On Error Resume Next
'***************************************
' Change this range if the units change

With mybook.Worksheets("data_1") 'sheet data copied from
Set sourceRange = .Range("a5:D50")
'range that is copied
End With


PROBLEM:-
On my machine it opens and extracts from both xls and xlsx files. Which is great.

The problem that I am encountering is that when I send this to a colleague it will only work on xls files.


Is it something to do with the configuration of excel (2007) or a code problem?

Or is my code a bit sh1tty, and needs improving?

Any suggestions?
</SPAN>
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
Bounce.
If I change the code to copy xlsx file types only it will only copy the first file info.

Any ideas, please?
 
Upvote 0

Forum statistics

Threads
1,202,909
Messages
6,052,493
Members
444,587
Latest member
ezza59

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top