Welcome to Tech Support Forum home to more then 136,000 problems solved. Issues have included: Spyware, Malware, Virus Issues, Windows, Microsoft, Linux, Networking, Security, Hardware, and Gaming Getting your problem solved is as easy as:
1. Registering for a free account
2. Asking your question
3. Receiving an answer

Registered members:
* Get free support
* Communicate privately with other members (PM).
* Removal of this message
* See fewer ads.
* And much more..

 



Want to know how to post a question? click here Having problems with spyware and pop-ups? First Steps
Go Back   Tech Support Forum > Microsoft Support > Microsoft Office support
User Name
Password
Site Map Register Donate Rules Blogs Mark Forums Read


Microsoft Office support MS Office support forum

Reply
 
LinkBack Thread Tools
Old 10-15-2008, 03:31 AM   #1 (permalink)
Registered User
 
Join Date: Oct 2008
Posts: 3
OS: XP


Need help with macros in Word 2003

Hi!

I've got some problems with the macro function in Word 2003. I'm swedish so if my spelling and grammar are'nt top notch thats the reason.

Anyway. I've been assigned to a very repetative task at my workplace and i think macros could help me alot.

I'm supposed to change company name in an allready existing document and then save the document with the company's name, and then repeat the whole thing like a million times with different company names.

This is how I do it at the moment:
Write the name of the company in the right place in the document > mark the name of the company > copy > save as > paste the company name > save.

Is it possible to create a macro so that I only have to do the first steps like this:
Write the name of the company > mark the name > the macro does the rest.

Any help would be much appreciated!

//Lucas, Sweden
Alvest is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Important Information
Join the #1 Tech Support Forum Today - It's Totally Free!

TechSupportForum.com is a leading support website for your computer needs. We offer free, friendly and personalized computer support. Why pay to have your computer fixed when you can do it for free.

Join TechSupportforum.com Today - Click Here

Old 10-15-2008, 04:17 PM   #2 (permalink)
Registered User
 
Join Date: May 2008
Location: Baltimore, Maryland
Posts: 160
OS: Windows XP SP3


Re: Need help with macros in Word 2003

The following example may be helpful.

Code:
Sub SaveUtility()
    Dim fdir As String
    Dim fname As String
    Dim fspec As String
    Dim response As Long
    fdir = "C:\Documents and Settings\Default User\"
    fname = Selection.Text
    fspec = fdir & fname
    If Dir(fspec, vbArchive Or vbDirectory Or vbHidden Or vbNormal Or vbReadOnly Or vbSystem) > "" Then
        response = MsgBox(fspec & " exists. Overwrite?", vbYesNo + vbQuestion, "SaveUtility")
        If response = vbNo Then
            Exit Sub
        End If
    ElseIf Dir(fspec & ".doc", vbArchive Or vbDirectory Or vbHidden Or vbNormal Or vbReadOnly Or vbSystem) > "" Then
        response = MsgBox(fspec & ".doc exists. Overwrite?", vbYesNo + vbQuestion, "SaveUtility")
        If response = vbNo Then
            Exit Sub
        End If
    End If
    Selection.WholeStory
    Selection.Copy
    Documents.Add DocumentType:=wdNewBlankDocument
    Selection.PasteAndFormat wdPasteDefault
    ActiveDocument.SaveAs FileName:=fspec, FileFormat:=wdFormatDocument
End Sub
This macro stores the currently selected text in a variable, creates a new copy of the current document, and saves the copy with a filename based on the text that was selected.

The new document will not contain the macro code. The new document's name will normally end with the .doc extension. In the code, you can modify the value of the variable fdir to specify the folder where the new document will be saved.
David M58 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Old 10-16-2008, 12:50 AM   #3 (permalink)
Registered User
 
Join Date: Oct 2008
Posts: 3
OS: XP


Re: Need help with macros in Word 2003

Aaaaaaaaaah! Thanks alot! Works perfect and this will save me alot of time

Just one more question: what if I don't want the new file to pop up as a new window? I just want to keep working in the same document but with the new file name, just like you do when you go the normal way with File > Save As

No need to hurry, just wondering!

Once again: Thank you!

//Lucas
Alvest is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Old 10-16-2008, 10:13 AM   #4 (permalink)
Registered User
 
Join Date: May 2008
Location: Baltimore, Maryland
Posts: 160
OS: Windows XP SP3


Re: Need help with macros in Word 2003

If you don't want the new file to pop up as a new window, simply remove these lines from the code:

Code:
    Selection.WholeStory
    Selection.Copy
    Documents.Add DocumentType:=wdNewBlankDocument
    Selection.PasteAndFormat wdPasteDefault
David M58 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Old 10-17-2008, 12:48 AM   #5 (permalink)
Registered User
 
Join Date: Oct 2008
Posts: 3
OS: XP


Re: Need help with macros in Word 2003

Aha, that's what I thought but i wasn't sure enough to try it out.

I finished all the documents yesterday thanks to your code, it made my work alot easier. Now i just have to print every document, double check them and put them in envalopes. I suppose you don't have a macro for that to..

Anyway, thanks for the help, the code might come in handy in the future too.
//Lucas
Alvest is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Reply


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




All times are GMT -7. The time now is 08:25 PM.



Copyright 2001 - 2009, Tech Support Forum
Home Tips Plus | Outdoor Basecamp | Automotive Support Forum

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85