Forum Discussion

serpiva64's avatar
serpiva64
Copper Contributor
Jan 26, 2023

Copying a query from a protected file

Hi,

why is possible to copy a query if the file is protected with Protect structure

 

as you can see if you try, the copy is an option always enabled

 

and it is possible to copy and paste the query in another file

Thank you very much if someone has a solution to avoid copying

 

3 Replies

  • NikolinoDE's avatar
    NikolinoDE
    Platinum Contributor

    serpiva64 

    I'm not sure if it works with PQ without problems, you could try it with VBA.
    I also don't know your digital environment (Excel version, operating system, storage medium, etc.),

    so I'm not sure whether VBA could be a solution at all in your digital environment.

     

    Whatever the case, the proof of the pudding is in the studying :).

    Attached is the VBA code and an example file.

    Option Explicit
    Private Sub Workbook_Activate()
    Application.CutCopyMode = False
    End Sub
    Private Sub Workbook_SheetActivate(ByVal Sh As Object)
    Application.CutCopyMode = False
    End Sub
    Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Range)
    Application.CutCopyMode = False
    End Sub

     

    Hope I could help you with these information.

     

    NikolinoDE

    I know I don't know anything (Socrates)

    • serpiva64's avatar
      serpiva64
      Copper Contributor
      Excel
      Microsoft® Excel® for Microsoft 365 MSO (Version 2212 Build 16.0.15928.20196) 64-bit
      Windows
      Edition Windows 11 Home
      Version 22H2
      Installed on ‎02/‎10/‎2022
      OS build 22621.1105
      Experience Windows Feature Experience Pack 1000.22638.1000.0
    • serpiva64's avatar
      serpiva64
      Copper Contributor

      NikolinoDE 

      this is the problem that i think i can't solve that way

      i've protected the file this way

       

       

Resources