Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8273371
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T07:28:14+00:00 2026-06-08T07:28:14+00:00

How to open a Workbook with a password, disable events, and then copy a

  • 0

How to open a Workbook with a password, disable events,
and then copy a sheet in background to the second file and save.
I need in VBA, working in a MS-Access and Excel files

I have done this until now, is working.

Private Sub TestFunction()

'strPath = CurrentDb.Properties(0)
'strPath = Left(strPath, Len(strPath) - Len(Dir(strPath, vbNormal))) & "Temp\"
Dim CopyFrom As Object
Dim CopyTo As Object ''Early binding: Workbook
Dim CopyThis As Object
Dim xl As Object ''Early binding: New Excel.Application

Set xl = CreateObject("Excel.Application")
xl.Visible = True
Set CopyFrom = xl.Workbooks.Open("D:\A01.xls")
'CopyFrom.EnableEvents = False
Set CopyThis = CopyFrom.Sheets(1) ''Sheet number 1
Set CopyTo = xl.Workbooks.Open("D:\PM1.xls")
CopyThis.Copy After:=CopyTo.Sheets(CopyTo.Sheets.Count)
CopyFrom.Close
End Sub

This opens the Excel, I enter the pass copy’s the sheet to second File.

But I need to pass the password in background, delete the sheet and save the second file, all in background.
Also I need to delete a sheet, without asking me, like :

CopyTo.Sheets("Sheet1").Delete

Thank you

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T07:28:17+00:00Added an answer on June 8, 2026 at 7:28 am

    Password issue

    Be careful to check wether it is an “open file” password (password parameter) or a “modify file” password (WriteResPassword parameter).

    Something like:

    Sub OpenMyFile()
        Workbooks.Open Filename:="Path", Password:="OpenFile", WriteResPassword:="WriteFile"
    End Sub
    

    Delete without alert

    For your second question, here is what you can do:

    Application.DisplayAlerts=False
    CopyTo.Sheets("Sheet1").Delete
    Application.DisplayAlerts=True
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to open excel 2003 workbook and save it as something else,
This is how I can open an excel file in vbA: Workbooks.Open(file-path) is there
I am trying to copy an excel sheet from one workbook to another without
I need to access an excel file that is already open. I thought just
I have an excel file with VBA macro that starts when the Workbook is
This is in continuation to my previous question ( Open Excel Workbook with vba
What's the way to open a excel workbook and to read excel cells?
I'm trying to open a write-protected ms excel 2007 file using win32com in python
In my asp page, I have to open a csv file in IE by
I need to populate several comboboxes in an Excel sheet upon loading it. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.