Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 03-11-2014, 04:45 AM
Catty Catty is offline Disabling Word's Save and SaveAs commands Windows 7 32bit Disabling Word's Save and SaveAs commands Office 2010 32bit
Advanced Beginner
Disabling Word's Save and SaveAs commands
 
Join Date: Nov 2013
Posts: 39
Catty is on a distinguished road
Default

Hi, Thanks for your response.



What I want to do is:

1. Fill in 3 fields (content controls) on the document i.e. Name, Date (DateTimePicker) and Subject.
2. When the user Selects/Clicks on Save/Save As, the dialog box needs to display and
i) All the content in the 3 fields needs to be combined and displayed in the "File Name" field of the dlgbox
ii) The dlgbox needs to open from a specified path.


Below is my code. But for some reason, one minute it works and the next it doesn't. Please have a look and let me know what I'm doing wrong.

Code:
Sub FileSave()
'
' FileSave Macro
' Saves the active document or template
'
Dim strName As String, strDate As String, strSubject As String
Dim strDocName As String
Dim dlgSaveAs As FileDialog
Dim ccCtrl As ContentControl

On Error GoTo errhandler:

Set dlgSaveAs = Application.FileDialog(msoFileDialogSaveAs)

With ActiveDocument
strName = .ContentControls("1017512746").Range.Text

strDate = .ContentControls("2985804456").Range.Text

strSubject = .ContentControls("821630576").Range.Text
End With

strDocName = strName & "_" & strDate & "_" & strSubject

With dlgSaveAs

    If .Show = -1 Then
        .InitialFileName = "C:\" & strDocName
        .Title = strDocName

        ActiveDocument.SaveAs2 (strDocName)

    Else
    MsgBox ("Document not saved!")
    End If
        
End With

errhandler:
'MsgBox ("Error saving the document!")

End Sub
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Disabling Word's Save and SaveAs commands When I try to save an existing word doc, save as pops up and will not save... samanthab Word 3 01-19-2013 06:27 AM
Disabling Word's Save and SaveAs commands Saveas error handling jillapass Word VBA 7 03-30-2012 03:24 PM
Keyboard Commands korric Word 3 02-09-2012 12:52 AM
Disabling Word's Save and SaveAs commands saveAs ChDir _ tinfanide Excel Programming 4 11-05-2011 01:40 AM
Advance Commands Richard1 Word 0 02-10-2011 01:35 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 05:45 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft