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

  • Home
  • SEARCH
  • 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 4078354
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T17:39:50+00:00 2026-05-20T17:39:50+00:00

I have an excel document that queries an SQL Database on button press. The

  • 0

I have an excel document that queries an SQL Database on button press. The document needs to be read-only. Currently, with the fields locked, on button press I receive the following run time error:

Run-time error '1004':

The cell or chart that you are trying to change is protected and therefore read-only.

I’ve done some searching and I can find some ways to open read-only/password protected files, but not how to apply changes to the protected rows while the file is read-only.

This is the code I currently have at the beginning of the module:

Sub Update()
Application.Calculation = xlCalculationManual


Dim Cnn As Object
Dim rstTmp As Object
  Dim appExcel As Excel.Application
  Dim wbkReport As Excel.Workbook
  Dim wksReport As Excel.Worksheet

Set Cnn = CreateObject("ADODB.Connection")
Set rstTmp = CreateObject("ADODB.Recordset")


Cnn.Open "Driver={SQL Server};Server=IPHERE;;UID=NOPE;PWD=ALMOST;DATABASE=DB;Trusted_Connection=No"

I’m trying to “reverse engineer” this functionality into a current excel. I have little to no experience with this so I am just jumping headlong into the deep end.

If any additional information is needed, I will be happy to add it.

Thanks in advance!

  • 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-05-20T17:39:50+00:00Added an answer on May 20, 2026 at 5:39 pm

    Use the following:

    Private Sub Workbook_Open()
        Dim wSheet As Worksheet
        For Each wSheet In Worksheets
            wSheet.Protect UserInterFaceOnly:=True
        Next wSheet
    End Sub
    

    This will lock all sheets in the user interface, but allow scripts to modify anything. You should put it in the load script for the book, because closing the program and reopening it will cause the protection to revert to full protection again. So it must be run every time the file opens.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an Excel document containing the details of 2000 users that need to
I'm hoping that I can explain this well enough. I have an excel document
I have an Excel document that has a single column of strings (around 400
I have a large excel document that is generated when the user clicks on
I have an XML document that is pretty much structured like an Excel spreadsheet
I have one excel document with two columns. i only add text in one
I have to work with text that was previously copy/pasted from an excel document
I have an Excel document (2007) with a chart (Clustered Column) that gets its
Possible Duplicate: Open excel document in java I have a button in my Java
I have an Excel document that contains over 1000 sheets of contact information of

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.