Note: The other languages of the website are Google-translated. Back to English
Logáil isteach  \/ 
x
or
x
Cláraigh  \/ 
x

or

Conas roghanna Sábháil & Sábháil Mar Excel a dhíchumasú nó gan iad a cheadú?

De ghnáth, nuair a chliceálann muid feidhm Save or Save As, sábhálfar ár sonraí modhnaithe sa leabhar oibre ag an am céanna. Ach, uaireanta, ní cheadaítear d’úsáideoirí eile do chomhad Excel a mhodhnú agus a shábháil nuair a léann siad an comhad. Soláthraíonn an t-alt seo modh VBA chun na roghanna Save & Save As in Excel a dhíchumasú.

Díchumasaigh Sábháil & Sábháil Mar roghanna le cód VBA


Díchumasaigh Sábháil & Sábháil Mar roghanna le cód VBA

Féadfaidh tú an cód VBA thíos a rith chun na roghanna Sábháil & Sábháil Mar in Excel a dhíchumasú.

1. Sa leabhar oibre ní mór duit na feidhmeanna Sábháil & Sábháil Mar a dhíchumasú, brúigh le do thoil Eile + F11 eochracha ag an am céanna chun an Microsoft Visual Basic d’Fheidhmchláir fhuinneog.

2. Sa Microsoft Visual Basic d’Fheidhmchláir fuinneog, cliceáil dúbailte An Leabhar Oibre seo sa bharra ar chlé, cóipeáil agus greamaigh an VBA 1 thíos i bhfuinneog an Chóid, agus ansin cliceáil ar an Sábháil cnaipe. Féach an pictiúr:

VBA 1: díchumasaigh na roghanna Sábháil & Sábháil Mar in Excel

Private Sub Workbook_BeforeClose(Cancel As Boolean)
    ThisWorkbook.Saved = True
End Sub

3. San oscailt Sábháil Mar fuinneog, roghnaigh fillteán chun an leabhar oibre a shábháil, ainmnigh an leabhar oibre de réir mar is gá duit agus roghnaigh Leabhar Oibre Macra-Chumasaithe Excel ó na Ach amháin mar chineál liosta anuas, agus ar deireadh cliceáil ar an Sábháil cnaipe.

4. Anois cóipeáil agus greamaigh an VBA 2 thíos sa An Leabhar Oibre seo fuinneog cód. Féach an pictiúr.

VBA 2: díchumasaigh na roghanna Sábháil & Sábháil Mar in Excel

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Dim xName As String
xName = "CancelBeforeSave"

If Not Evaluate("=ISREF('" & xName & "'!A1)") Then
    Sheets.Add(after:=Worksheets(Worksheets.count)).Name = xName & ""
    Sheets(xName & "").Move after:=Worksheets(Worksheets.count)
    Sheets(xName & "").Visible = False
    Exit Sub
End If
    Cancel = True
End Sub

5. Cliceáil ar an Sábháil cnaipe chun an cód a shábháil, agus ansin an leabhar oibre a dhúnadh.

Sábháladh an leabhar oibre mar Leabhar Oibre Macra-Chumasaithe Excel leis an Sábháil agus Sábháil Mar feidhmeanna faoi mhíchumas.

nótaí: Dealraíonn sé go sábhálfar athruithe sa bhileog oibre reatha gach uair a dhéanann tú an leabhar oibre a mhodhnú agus a shábháil. Ach tar éis duit an leabhar oibre a dhúnadh agus a athoscailt, gheobhaidh tú gur theip ar na hathruithe a shábháil.


Na hUirlisí Táirgiúlachta Oifige is Fearr

Réitíonn Kutools for Excel an chuid is mó de do chuid Fadhbanna, agus Méadaíonn sé do Tháirgiúlacht 80%

  • Athúsáid: Cuir isteach go tapa foirmlí casta, cairteacha agus aon rud a d'úsáid tú roimhe seo; Cealla a Chriptiú le pasfhocal; Cruthaigh Liosta Ríomhphoist agus seol ríomhphoist ...
  • Barra Foirmle Super (cuir línte iolracha téacs agus foirmle in eagar go héasca); Leagan Amach Léitheoireachta (líon mór cealla a léamh agus a chur in eagar go héasca); Greamaigh go dtí an Raon Scagtha...
  • Cumaisc Cealla / Sraitheanna / Colúin gan Sonraí a chailleadh; Ábhar Cealla Scoilt; Comhcheangail Sraitheanna / Colúin Dúblacha... Cill Dúblach a Chosc; Déan comparáid idir Ranganna...
  • Roghnaigh Dúblach nó Uathúil Sraitheanna; Roghnaigh Blank Rows (tá na cealla uile folamh); Aimsigh Super agus Fuzzy Aimsigh i go leor Leabhar Oibre; Roghnaigh go randamach ...
  • Cóip Díreach Cealla Il gan tagairt fhoirmle a athrú; Tagairtí Cruthaigh Auto chuig Bileoga Il; Cuir Urchair isteach, Boscaí Seiceála agus go leor eile ...
  • Sliocht Téacs, Cuir Téacs leis, Bain de réir Poist, Bain Spás; Subtotals Paging a chruthú agus a phriontáil; Tiontaigh Idir Ábhar Cealla agus Tráchtanna...
  • Scagaire Super (scéimeanna scagaire a shábháil agus a chur i bhfeidhm ar bhileoga eile); Ard-Sórtáil de réir míosa / seachtaine / lae, minicíocht agus níos mó; Scagaire Speisialta le cló trom, iodálach ...
  • Comhcheangail Leabhair Oibre agus Bileoga Oibre; Cumaisc Táblaí bunaithe ar eochaircholúin; Roinn Sonraí i Ilbhileoga; Baisc Tiontaigh xls, xlsx agus PDF...
  • Níos mó ná 300 gné chumhachtach. Tacaíochtaí Office / Excel 2007-2019 agus 365. Tacaíonn sé le gach teanga. Imscaradh éasca i d’fhiontar nó d’eagraíocht. Gnéithe iomlána triail saor in aisce 30 lá. Ráthaíocht ar ais airgid 60 lá.
cluaisín kte 201905

Tugann Tab Oifige comhéadan Tabbed chuig Office, agus Déan Do Obair i bhfad Níos Éasca

  • Cumasaigh eagarthóireacht agus léamh tabbed i Word, Excel, PowerPoint, Foilsitheoir, Rochtain, Visio agus Tionscadal.
  • Oscail agus cruthaigh cáipéisí iolracha i gcluaisíní nua den fhuinneog chéanna, seachas i bhfuinneoga nua.
  • Méadaíonn do tháirgiúlacht 50%, agus laghdaíonn sé na céadta cad a tharlaíonn nuair luch duit gach lá!
bun officetab
Say something here...
symbols left.
You are guest
or post as a guest, but your post won't be published automatically.
Loading comment... The comment will be refreshed after 00:00.
  • To post as a guest, your comment is unpublished.
    Joe · 8 months ago
    Please, I do not want someone to copy or save my excel file, how can I remove save or save as?

  • To post as a guest, your comment is unpublished.
    Madhusudhan · 9 months ago
    Hello I am a fan of this website...I used to try the code. It works flawlessly. But it disables "Save option" too. I am not able to save the Excel sheet. What I need is to disable only the feature "Save As" I read the other user's comments too. ThisWorkbookSaved = True is not working for me as well. Could you please help? Thanks a lot for all your contributions.
  • To post as a guest, your comment is unpublished.
    Naomi · 1 years ago
    I keep getting debug error
    • To post as a guest, your comment is unpublished.
      crystal · 1 years ago
      Good day,
      Which Excel version do you use?
  • To post as a guest, your comment is unpublished.
    Rogue · 3 years ago
    Just to help whoever else reads this article looking for help with suppressing the save button I thought I'd place the answer down here as "Crystal" doesn't seem to be answering the question....


    If you place the workbook in "Design Mode" and then hit SAVE it should work.
    • To post as a guest, your comment is unpublished.
      crystal · 3 years ago
      Dear Rogue,
      I miss the point of the problem. Thank you so much for your help and sharing.

      Best Regards
  • To post as a guest, your comment is unpublished.
    What they said · 3 years ago
    As TEE and LES posted, how do we save the file with the macro in?
    • To post as a guest, your comment is unpublished.
      crystal · 3 years ago
      Hi,
      Thank you for your question. The article is updated to support saving the code into workbook now.
  • To post as a guest, your comment is unpublished.
    Les Battersthee · 3 years ago
    As TEE posted, how do we save the file with the macro in? It is not there when I reopen. I am also now getting a bug on the ThisWorkbookSaved = True bit.
    • To post as a guest, your comment is unpublished.
      crystal · 3 years ago
      Dear Les,
      Thank you for your question. The article is updated to support saving the code into workbook now.
  • To post as a guest, your comment is unpublished.
    tee · 4 years ago
    this doesn't work. I can't save the code it's gone once I reopen the file. How do I save the code?
    • To post as a guest, your comment is unpublished.
      crystal · 3 years ago
      Dear tee,
      Thank you for your question. The article is updated to support saving the code into workbook now.
      • To post as a guest, your comment is unpublished.
        jen · 2 years ago
        dear
        the article is not updated. it doesnt work
        • To post as a guest, your comment is unpublished.
          crystal · 2 years ago
          Hi jen,
          The article has been updated again with the problem solving. Please have a try. Thank you for your comment.
          • To post as a guest, your comment is unpublished.
            I.C. Problems · 1 years ago
            The update to the code adds a sheet, but never actually checks whether there is a TRUE/FALSE value in that sheet. The update fixes nothing, it just creates a useless sheet within the workbook.

            I think you forgot to do a check whether there is a TRUE/FALSE value on that sheet.