Quantcast
Channel: Word for Developers forum
Viewing all articles
Browse latest Browse all 4350

How To Disable Save, Save As , Export buttons in MS-Word 2013 using VBA.

$
0
0

Hi Experts,

I am using Office 2013. I want to disable Save, Save As, Export buttons in a Word Document using VBA . By 'Disable' I mean, user should not be able to click on these buttons. I have tried disabling these buttons using 

Word.CommandBars("File").Controls("&Save").Enabled = False

Word.CommandBars("File").Controls("&Save").Visible = False

And same for "Save As" .But this has no effect on the document and I was still able to use Save and SaveAs buttons. How can I disable these buttons ?

Another problem I am facing is with 'Export' button. The UI shows the Export button under "File" menu but when I iterate the File menu it shows no entry of 'Export'. VBA code I am using to iterate the File menu is :   

Dim ctl As CommandBarControl
    Dim cmd As CommandBar
    Dim menuItems As String

    MyFile1 = "C:\tmp\outputFromWord.txt"
    fnum1 = FreeFile()
    Open MyFile1 For Output As fnum1

    Set cmd = CommandBars("File")

    For Each ctl In cmd.Controls
       menuItems = ctl.Caption + "  ----> " + ctl.DescriptionText
       Print #fnum1, menuItems
    Next

Close #fnum1

What am I doing wrong here.?

Thanks

rsKRISH


Viewing all articles
Browse latest Browse all 4350

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>