Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 12-10-2014, 07:29 PM
tingker tingker is offline help creating macro Windows 7 64bit help creating macro Office 2010 64bit
Novice
help creating macro
 
Join Date: Dec 2014
Posts: 6
tingker is on a distinguished road
Default help creating macro

Hello all,
I have about 200 files that I need to edit and I was wondering if someone can help me create a macro that will make my life a little easier.

I have to insert a text before each question (see below -in red). There's about 20 questions per document. Is there an easy way of doing this with macro? Instead of copy and pasting. Many thanks, any feedback is greatly appreciated!

<cgi=”0000000000” type=”mc”>
1. Which Microsoft Word feature allows you to create individual form letters?
A. Envelopes and Labels
B. Macro
C. Mail Merge
D. AutoText

<cgi=”0000000000” type=”mc”>
2. To save an existing document with an alternative name you would….
A. Click on the Save button
B. Select File, Save As from the menu bar
C. Select File, New from the menu bar
D. Click on the Open button
Reply With Quote
  #2  
Old 12-10-2014, 11:20 PM
macropod's Avatar
macropod macropod is offline help creating macro Windows 7 64bit help creating macro Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
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 the following macro. It includes a folder browser, so all you need do is select the folder to process.
Code:
Sub UpdateDocuments()
Application.ScreenUpdating = False
Dim strFolder As String, strFile As String, strDocNm As String, wdDoc As Document
strDocNm = ActiveDocument.FullName
strFolder = GetFolder
If strFolder = "" Then Exit Sub
strFile = Dir(strFolder & "\*.doc", vbNormal)
While strFile <> ""
  If strFolder & "\" & strFile <> strDocNm Then
    Set wdDoc = Documents.Open(FileName:=strFolder & "\" & strFile, AddToRecentFiles:=False, Visible:=False)
    With wdDoc
      With .Range.Find
        .ClearFormatting
        .Text = "^13[0-9]@."
        .Replacement.Text = "^p<cgi=”0000000000” type=”mc”>^&"
        .Forward = True
        .Wrap = wdFindContinue
        .Format = False
        .MatchWildcards = True
        .Execute Replace:=wdReplaceAll
      End With
      .Close SaveChanges:=True
    End With
  End If
  strFile = Dir()
Wend
Set wdDoc = Nothing
Application.ScreenUpdating = True
End Sub
 
Function GetFolder() As String
Dim oFolder As Object
GetFolder = ""
Set oFolder = CreateObject("Shell.Application").BrowseForFolder(0, "Choose a folder", 0)
If (Not oFolder Is Nothing) Then GetFolder = oFolder.Items.Item.Path
Set oFolder = Nothing
End Function
For PC macro installation & usage instructions, see: http://www.gmayor.com/installing_macro.htm
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 12-11-2014, 08:54 AM
tingker tingker is offline help creating macro Windows 7 64bit help creating macro Office 2010 64bit
Novice
help creating macro
 
Join Date: Dec 2014
Posts: 6
tingker is on a distinguished road
Default

Thank you so much! works perfectly!!!
Reply With Quote
  #4  
Old 01-08-2015, 09:46 AM
tingker tingker is offline help creating macro Windows 7 64bit help creating macro Office 2010 64bit
Novice
help creating macro
 
Join Date: Dec 2014
Posts: 6
tingker is on a distinguished road
Default

Hello Macropod, Just a quick question, they have updated my office to 2013 and now the macro is not working. Can you help please!

Thanks in advance!
Reply With Quote
  #5  
Old 01-08-2015, 08:58 PM
macropod's Avatar
macropod macropod is offline help creating macro Windows 7 64bit help creating macro Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
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

There is nothing about the macro that is specific to any Word version, so I can't see any reason it wouldn't work with Office 2013.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
help creating macro Need Help Creating Macro rsrasc Word VBA 1 10-22-2014 03:09 PM
help creating macro Need Help Creating Macro rsrasc Word VBA 4 03-28-2014 01:31 PM
help creating macro Creating a generic macro? suerose Word 2 07-04-2011 07:59 PM
Creating a MACRO Nikb3522 Word VBA 0 10-21-2010 05:55 PM
creating macro steveb Word VBA 0 08-14-2010 01:29 AM

Other Forums: Access Forums

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