Solved

MS Word Macro - Save on open to specific directory

Posted on 2010-08-27
5
537 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 200 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 300 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

Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

Question has a verified solution.

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

This article describes how to use the Send to Mail Recipient command. The instructions apply generally to Office 2007 and later versions, but Microsoft® Word 2013 was used for the specific steps and figures.  What is Send to Mail Recipient? Send…
Using Word 2013, I was experiencing some incredible lag when typing.  Here's what worked for me....
This video shows the viewer how to set up and create Footnotes in their document. Click on the References tab: Select "Insert Footnote": Type in desired text:
The viewer will learn how to simulate a series of sales calls dependent on a single skill level and learn how to simulate a series of sales calls dependent on two skill levels. Simulating Independent Sales Calls: Enter .75 into cell C2 – “skill leve…
Suggested Courses

636 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