#1
|
|||
|
|||
Word Macro saving with different filename
i need help i don't know anything about writing scripts. what i'm trying to do is as follows: "copy text from anywhere" paste the text into word, save the file with a different filename everytime, in the same directory, close the file, open a new blank file the Macro i recorded as follows. 1: ctrl +v 2: F12 3: ctrl +w 4: ctrl +n It works the first time, the SaveAs dialog box pops up, paste the proper filename, close, open new. Running it the second time around it justs overwrites the contents of the file, and saves it with the previous filename used. Since I'm asking for a SaveAS, should it not prompt me for a filename? How do I get the SaveAs Dialog box everytime, or have the macro grab the last entry from the clipboard, and use that as a filename? |
#2
|
||||
|
||||
The macro recorder only records the processes, not necessarily the dialogue boxes etc. you used to get them. Instead of the code you now have for the SaveAs, you should use:
Application.Dialogs(wdDialogFileSaveAs).Display That will give you the SaveAs dialogue box, so you can choose the new name.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#3
|
|||
|
|||
Quote:
I tried replacing the SaveAs dialogue box as you suggested, but i keep getting syntax error, or expected end of statement error msgs. Where am i going wrong? Thx! Code:
Sub Macro1() ' ' Macro1 Macro ' ' Selection.Paste ActiveDocument.SaveAs FileName:="just some dummy text for testin1.docx", _ FileFormat:=wdFormatXMLDocument, LockComments:=False, Password:="", _ AddToRecentFiles:=True, WritePassword:="", ReadOnlyRecommended:=False, _ EmbedTrueTypeFonts:=False, SaveNativePictureFormat:=False, SaveFormsData _ :=False, SaveAsAOCELetter:=False ActiveWindow.Close Documents.Add DocumentType:=wdNewBlankDocument End Sub Last edited by macropod; 11-05-2013 at 01:58 PM. Reason: Added code tags & formatting |
#4
|
||||
|
||||
Try something along the lines of:
Code:
Sub Demo() Selection.Paste With Application.Dialogs(wdDialogFileSaveAs) .Name = "just some dummy text for testin1.docx" If .Show = -1 Then ActiveDocument.Saved = True End With ActiveDocument.Close , False Documents.Add DocumentType:=wdNewBlankDocument End Sub
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#5
|
|||
|
|||
intial testing works, I'll try it out in the real life situation and post back
Thx! |
#6
|
|||
|
|||
the project was cancelled..my bad forgot to post back.
THX!!! All |
Thread Tools | |
Display Modes | |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Saving as ( PowerPoint Macro-Enabled Slide Show )?? | delete123 | PowerPoint | 2 | 04-10-2013 05:38 AM |
A macro that can insert FILENAME, sendkeys CTRL ALT T, paste clipboard, and nextline | kyjac85 | Word VBA | 13 | 09-20-2012 05:00 PM |
Problem saving in Word 2007 a dotm Addin developed in Word 2010 | RichardP | Word VBA | 6 | 04-26-2012 04:22 AM |
Macro for automatically adding filename without .doc | RPM7 | Word VBA | 0 | 04-29-2010 01:43 AM |
Word: The document 'Filename' caused a serious error the last time ... | martincruise | Word | 0 | 02-25-2010 01:47 AM |