![]() |
#1
|
|||
|
|||
![]()
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. |
#2
|
||||
|
||||
![]()
Word Basic? It has been a seriously long time since I used that, and its continued use has built-in obsolescence. I seem to recall that it is not fully supported in the most recent Word versions, but don't hold me to it.
Once the document has been merged the fields are replaced with the merge data, so you would have to split the line and delete the redundant information to get the required data. Frankly I would bring your process kicking and screaming into the 21st century and use http://www.gmayor.com/individual_merge_letters.htm. or http://www.gmayor.com/MergeAndSplit.htm to name your document from the data, with or without added text.
__________________
Graham Mayor - MS MVP (Word) (2002-2019) Visit my web site for more programming tips and ready made processes www.gmayor.com |
#3
|
|||
|
|||
![]()
How do I go about bring this into the 21st century, this was built by a past employee and know very little about VBA.
I know how to record macros but this is way above my learning. |
#4
|
||||
|
||||
![]()
No knowledge of macros is required if you use one of my add-ins, which will work with Word versions from 2007 to the present version.
If there are multiple record items per letter i.e. a Many to One merge then see http://www.gmayor.com/ManyToOne.htm
__________________
Graham Mayor - MS MVP (Word) (2002-2019) Visit my web site for more programming tips and ready made processes www.gmayor.com |
![]() |
|
![]() |
||||
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 |
![]() |
rvessio | Word VBA | 4 | 07-25-2016 12:37 PM |
![]() |
brmveen | Word VBA | 2 | 11-04-2015 12:51 AM |
![]() |
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 |