+ Reply to Thread
Results 1 to 3 of 3

Need help unprotecting workbook before importing

  1. #1
    Registered User
    Join Date
    04-21-2004
    Posts
    19

    Need help unprotecting workbook before importing

    I'm trying to import a workbook into an open workbook using the code below, however, the workbook I'm trying to import has a password. The password is blank (essentially no password).

    Sheets.Add Type:= "E:\mattw\My Documents\My Timesheets - 2006.xls"

    So.... since it's "password protected" with a null password, how can I unprotect the workbook BEFORE importing it?? Do I have to open it, then remove the protection, or can I remove the protection while I'm inserting it?

    Thanks in advance!

    Matt W

  2. #2
    Dave Peterson
    Guest

    Re: Need help unprotecting workbook before importing

    Maybe you could just open the workbook, steal a copy of the worksheet and close
    that workbook:

    Option Explicit
    Sub testme()

    Dim wks As Worksheet
    Dim curWkbk As Workbook

    Set curWkbk = ActiveWorkbook

    Set wks = Workbooks.Open _
    (Filename:="c:\my documents\excel\book3.xls").Worksheets(1)

    wks.Copy _
    before:=curWkbk.Worksheets(1)

    wks.Parent.Close savechanges:=False

    End Sub

    BVHis wrote:
    >
    > I'm trying to import a workbook into an open workbook using the code
    > below, however, the workbook I'm trying to import has a password. The
    > password is blank (essentially no password).
    >
    > Sheets.Add Type:= "E:\mattw\My Documents\My Timesheets - 2006.xls"
    >
    > So.... since it's "password protected" with a null password, how can I
    > unprotect the workbook BEFORE importing it?? Do I have to open it,
    > then remove the protection, or can I remove the protection while I'm
    > inserting it?
    >
    > Thanks in advance!
    >
    > Matt W
    >
    > --
    > BVHis
    > ------------------------------------------------------------------------
    > BVHis's Profile: http://www.excelforum.com/member.php...fo&userid=8593
    > View this thread: http://www.excelforum.com/showthread...hreadid=502238


    --

    Dave Peterson

  3. #3
    Registered User
    Join Date
    04-21-2004
    Posts
    19
    Can I copy multiple worksheets in one shot doing it that way, or would I have to copy 1 worksheet at a time??

    Matt W

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1