Keeping Macros intact

J

Jay

I'm trying to create 2 different macros in word 03'. I think I'm doing
everything correctly, but when I go to save the 2nd macro, the 1st one I
recorded starts to mimic the new macro. I'm not sure if it's a naming
problem, a placement problem or what. Can anyone help?
 
J

Jay

Thanks for the help Doug. Although my question wasn't answered, you've
sparked enough curiousity now that I'm going to go learn VBA. I was using
the macro recorder, which is a nice tool, but I can see now just how powerful
VBA is.

My redefined situation is this. My company has merged with another and all
the quality documents (over 6000) need their header replaced with a new table
and logo. Also we're changing a signature page by adding another column,
from 2 to 3, for people to print their name.

This has to happen on all the documents so I'm looking to build a macro that
takes some of the repetitiveness out of this. My guess is that I'll need a
template with this new frame, logo and table to source for this to happen.

I'm going to muddle through the mvp site to see if I can solve this but any
help is appreciated.
 
G

Graham Mayor

Thats something of a leap from recording a macro and the learning curve is
going to be quite steep. A good place to start would be
http://gregmaxey.mvps.org/VBA_Basics.htm. Then for the batch macro code you
would need the following which will open and close each document in a
selected folder. If you don't know how to use listings - see
http://www.gmayor.com/installing_macro.htm

Sub BatchProcess()
Dim strFilename As String
Dim strPath As String
Dim oDoc As Document
Dim fDialog As FileDialog
Set fDialog = Application.FileDialog(msoFileDialogFolderPicker)

With fDialog
.Title = "Select folder and click OK"
.AllowMultiSelect = False
.InitialView = msoFileDialogViewList
If .Show <> -1 Then
MsgBox "Cancelled By User", , _
"List Folder Contents"
Exit Sub
End If
strPath = fDialog.SelectedItems.Item(1)
If Right(strPath, 1) <> "\" _
Then strPath = strPath + "\"
End With

If Documents.Count > 0 Then
Documents.Close SaveChanges:=wdPromptToSaveChanges
End If
If Left(strPath, 1) = Chr(34) Then
strPath = Mid(strPath, 2, Len(strPath) - 2)
End If
strFilename = Dir$(strPath & "*.doc")

While Len(strFilename) <> 0
Set oDoc = Documents.Open(strPath & strFilename)
'
'Do what you want with oDoc
'
oDoc.Close SaveChanges:=wdSaveChanges
strFilename = Dir$()
Wend
End Sub


As to what to do with the documents (oDoc) when they are opened rather, this
depends on what *exactly* you want to change. When you have worked it out
for one document, post your further questions in the Word vba forum.

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
J

Jay

Graham,

Thanks for the reply. As I started reading the first link you sent, I kept
up until about halfway down and then crumbled. You're correct, learning VB
will be a steep curve. I'm going to need to crawl before I walk. I have a
very crude understanding of programming so I think the best place to start
may be with a simple class at a Comm College to get me started. Once I
really understand the basics then the curve flattens out... at least in my
case it does.

Thank you again for your assistance.
 
D

Doug Robbins - Word MVP

I think that your time would be better spent trying to develop a macro for
which you have a purpose rather than being bored to death in some Comm
College Class.

If you take this approach, and get stuck, post to the
microsoft.public.word.vba.general newsgroup.

--
Hope this helps,

Doug Robbins - Word MVP

Please reply only to the newsgroups unless you wish to obtain my services on
a paid professional basis.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Unable to save macros in word 2007 6
Combine two macros into one 3
Upgrade template to 2007 and lose macros 3
Macros will not stay 1
MACRO NOT WORKING 2
Macro will not stay 1
Macros in Word 1
Macros 1

Top