Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 06-07-2017, 08:19 PM
Beatle13 Beatle13 is offline Add {mergefieldnumber} to save name Windows 10 Add {mergefieldnumber} to save name Office 2010 64bit
Novice
Add {mergefieldnumber} to save name
 
Join Date: Jun 2017
Posts: 2
Beatle13 is on a distinguished road
Default Add {mergefieldnumber} to save name

Hi all,

The code below was written by a previous employee and have very little experience doing VBA programming.
Help how this should be written would of great assistance, to gmayor, how to do what you have below i have no idea.

I am trying to edit a VBA macro to add the {MERGEfIELD number} to the save file name.
the macro below is what I have but this only saves the file as Selectronic Purchase Order.doc.

the document data looks like this
Order Number: { MERGEFIELD number } Date: { MERGEFIELD date }
Order Number: 130465 Date: 07/06/2017

any help with this would save time and errors.

Sub OpenPurchaseOrdersSean()
'
' OpenPurchaseOrdersSean Macro
'
'
'
'
WordBasic.FileOpen Name:="c:\flexsoft\poprint."
WordBasic.FileSaveAs Name:="c:\flexsoft\Poprint.doc", Format:=0, LockAnnot:=0, Password:="", AddToMru:=1, WritePassword:="", RecommendReadOnly:=0, EmbedFonts:=0, NativePictureFormat:=0, FormsData:=0, SaveAsAOCELetter:=0

' Search and replace " characters
WordBasic.StartOfDocument


WordBasic.StartOfLine
WordBasic.EditFind Find:=Chr(34), Direction:=0, MatchCase:=0, WholeWord:=0, PatternMatch:=0, SoundsLike:=0, Format:=0, Wrap:=0
While WordBasic.EditFindFound()
WordBasic.InsertSymbol Font:="Symbol", CharNum:="178"
WordBasic.EditFind Find:=Chr(34), Direction:=0, MatchCase:=0, WholeWord:=0, PatternMatch:=0, SoundsLike:=0, Format:=0, Wrap:=0
Wend
' Search and replace ² characters
WordBasic.StartOfDocument
WordBasic.StartOfLine
WordBasic.EditFind Find:="ý", Direction:=0, MatchCase:=0, WholeWord:=0, PatternMatch:=0, SoundsLike:=0, Format:=0, Wrap:=0
While WordBasic.EditFindFound()
Selection.InsertSymbol CharacterNumber:=178, Unicode:=True
WordBasic.EditFind Find:="ý", Direction:=0, MatchCase:=0, WholeWord:=0, PatternMatch:=0, SoundsLike:=0, Format:=0, Wrap:=0
Wend
WordBasic.FileSave
WordBasic.FileClose
WordBasic.FileOpen Name:="U:\Purchasing\Sean\Selectronic Purchase Order.doc", ConfirmConversions:=0, ReadOnly:=0, AddToMru:=0, PasswordDoc:="", PasswordDot:="", Revert:=0, WritePasswordDoc:="", WritePasswordDot:=""
End Sub

Last edited by Beatle13; 06-08-2017 at 01:22 AM.
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Word 2016 Won't Save. Keeps Asking to Save As, But Doesn't CrossReach Word 3 03-11-2017 05:23 PM
Add {mergefieldnumber} to save name Macro to save as pdf with ability to choose save as folder rvessio Word VBA 4 07-25-2016 12:37 PM
Add {mergefieldnumber} to save name save dialog box promt doesn't save file brmveen Word VBA 2 11-04-2015 12:51 AM
Add {mergefieldnumber} to save name 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
Word ask to save template whenever i save a derived document jorbjo Word 3 10-04-2012 10:52 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 07:50 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