Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

MS Word Macro - Save on open to specific directory

Posted on 2010-08-27
5
Medium Priority
?
538 Views
Last Modified: 2012-06-27
Hi,

I have a Microsoft Word Document and when I open it I want it to automatically save it to a location specified in the code with the same name as the original.

Is this possble to achieve?

Thanks,
0
Comment
Question by:jasocke2
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
5 Comments
 
LVL 5

Expert Comment

by:INHOUSERES
ID: 33540630
Create a macro and call it "AutoExec".

Then you can put your code to save it in the macro and it'll run when you open it.
0
 
LVL 5

Assisted Solution

by:INHOUSERES
INHOUSERES earned 800 total points
ID: 33540674
scrap that.

Press ALT+F11 in the document you want.
On the right, expand "Microsoft Word Objects" and double click "ThisDocument".
Select "Document" and then "open", then put your code in.

e.g.

Private Sub Document_Open()
    FileName = "C:\temp\filename.doc"
    ActiveDocument.SaveAs FileName
End Sub
0
 

Author Comment

by:jasocke2
ID: 33540721
Thank's for your comments.

I work with Excel VBA quite often. Is it the same sort of syntax to Excel?
0
 
LVL 5

Expert Comment

by:INHOUSERES
ID: 33540767
Most of office collection has the same syntax. Access is probably the only exception, but not by much.

For example:

Excel: ActiveWorkbook
Word: ActiveDocument
Powerpoint: ActivePresentation
0
 
LVL 59

Accepted Solution

by:
Chris Bottomley earned 1200 total points
ID: 33540829
If yoiu simply save then the active document takes the save file name and you are no longer working on the original so try the following which saves the document, (change "c:\deleteme\" & ActiveDocument.FullName for your saved file name).

Chris


Private Sub Document_Open()
    ActiveDocument.Save
    Application.Documents.Add ActiveDocument.FullName
    ActiveDocument.SaveAs "c:\deleteme\" & ActiveDocument.FullName
    ActiveDocument.Close
End Sub

Open in new window

0

Featured Post

Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

As with any other System Center product, the installation for the Authoring Tool can be quite a pain sometimes. This article serves to help you avoid making these mistakes and hopefully save you a ton of time on troubleshooting :)  Step 1: Make sur…
The new Microsoft OS looks great, is easier than ever to upgrade to, it is even free.  So what's the catch?  If you don't change the privacy settings, Microsoft will, in accordance with the (EULA) you clicked okay to without reading, collect all the…
This video shows where to find the word count, how to display it, and what it breaks down to in Microsoft Word.
In a previous video Micro Tutorial here at Experts Exchange (http://www.experts-exchange.com/videos/1358/How-to-get-a-free-trial-of-Office-365-with-the-Office-2016-desktop-applications.html), I explained how to get a free, one-month trial of Office …

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question