Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 11-01-2013, 09:43 AM
terraterm terraterm is offline Word Macro saving with different filename Windows 7 64bit Word Macro saving with different filename Office 2007
Novice
Word Macro saving with different filename
 
Join Date: Nov 2013
Posts: 4
terraterm is on a distinguished road
Unhappy 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?
Reply With Quote
  #2  
Old 11-01-2013, 06:18 PM
macropod's Avatar
macropod macropod is offline Word Macro saving with different filename Windows 7 32bit Word Macro saving with different filename Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

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]
Reply With Quote
  #3  
Old 11-05-2013, 11:07 AM
terraterm terraterm is offline Word Macro saving with different filename Windows 7 64bit Word Macro saving with different filename Office 2007
Novice
Word Macro saving with different filename
 
Join Date: Nov 2013
Posts: 4
terraterm is on a distinguished road
Default

Quote:
Originally Posted by macropod View Post
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.
This is what my original macro looks like below.

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
Reply With Quote
  #4  
Old 11-05-2013, 02:02 PM
macropod's Avatar
macropod macropod is offline Word Macro saving with different filename Windows 7 32bit Word Macro saving with different filename Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

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]
Reply With Quote
  #5  
Old 11-18-2013, 01:13 PM
terraterm terraterm is offline Word Macro saving with different filename Windows 7 64bit Word Macro saving with different filename Office 2007
Novice
Word Macro saving with different filename
 
Join Date: Nov 2013
Posts: 4
terraterm is on a distinguished road
Default

intial testing works, I'll try it out in the real life situation and post back

Thx!
Reply With Quote
  #6  
Old 02-28-2014, 12:02 PM
terraterm terraterm is offline Word Macro saving with different filename Windows 7 64bit Word Macro saving with different filename Office 2007
Novice
Word Macro saving with different filename
 
Join Date: Nov 2013
Posts: 4
terraterm is on a distinguished road
Default

the project was cancelled..my bad forgot to post back.

THX!!! All
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Word Macro saving with different filename Saving as ( PowerPoint Macro-Enabled Slide Show )?? delete123 PowerPoint 2 04-10-2013 05:38 AM
Word Macro saving with different filename A macro that can insert FILENAME, sendkeys CTRL ALT T, paste clipboard, and nextline kyjac85 Word VBA 13 09-20-2012 05:00 PM
Word Macro saving with different filename 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

Other Forums: Access Forums

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


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