PDA

View Full Version : Macro to Save As with ActiveDocument name



shekhu
03-08-2011, 11:53 PM
Hi,

Through this macro I am able to save-as a copy of the active document, but when the window pops up it shows "Editor's Initials" to save the document name. The problem is that I do not want this, instead what I need is the name of the active document/current file here. Is it possible, please suggest.
Thanks for your help.

Sub Save_Audited_File()
Set dlgSaveAs = Dialogs(wdDialogFileSaveAs)
With dlgSaveAs
.Name = "\\WordBackupFolder\Error folder" & "\" & "Editor's Initials.doc"
.Format = wdFormatDocument
.Show
End With
End Sub

Frosty
03-09-2011, 08:46 AM
ActiveDocument.Name

?

shekhu
03-09-2011, 10:45 PM
I hope I am bad at making others understand things. Let me try again.
I have attached an image wherein the red circle says "Editor's Initials.doc".

What I need it should mentions the Name of the document on which I am running the macro to "save as".

It is similar to what we do in a word document "Save As", but if I record the macro it saves a document name in the code recorded. Thus when I run that macro on other documents, there is old document name as recorded in the code every time, not the current document name on which macro is run. I hope it is ActiveDocument.Name, I am not sure of the terminology.
Thanks for your cooperation.

RonMcK
03-10-2011, 07:45 AM
Hi, Shekhu,

I think Frosty was suggesting that you replace the file's name in your macro with ActiveDocument.Name. What happens when you execute your code after changing your sub to read, as follows?

Sub Save_Audited_File()
Set dlgSaveAs = Dialogs(wdDialogFileSaveAs)
With dlgSaveAs
.Name = "\\WordBackupFolder\Error folder" & "\" & ActiveDocument.Name
.Format = wdFormatDocument
.Show
End With
End Sub

Thanks,

fumei
03-10-2011, 09:58 AM
Why are you even using the dialog??? Why not just save it as a SaveAs, using whatever name you want, including whatever is the ActiveDocument name?

shekhu
03-10-2011, 10:28 PM
Thanks a lot Frosty, I couldn't get you earlier also thanks for explaining RonMcK.

Hi Gerry, the reason not using "Save As" function is that I need to save the audited copy in a network and it has a long path. Also, there are number or users who save the docs there, this is just for consistency, saving time, and to eliminate errors of saving files in a wrong folder.
Anyway, thanks for your concern.