Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Saving a Word document in a specified folder 3

Status
Not open for further replies.

bxgti4x4

Technical User
Feb 22, 2002
167
GB
A particular Word document is received by email every day. I open the document, print it and then want to save it in a particular folder.

I have the following code which saves the document with today's date:

Code:
 strDest = "N:\Access\Houston Updates\Current Month\" & Format(Date, "DD MMM") & ".doc"
        ActiveDocument.SaveAs FileName:=strDest, FileFormat:= _
        wdFormatDocument, LockComments:=False, Password:="", AddToRecentFiles:= _
        True, WritePassword:="", ReadOnlyRecommended:=False, EmbedTrueTypeFonts:= _
        False, SaveNativePictureFormat:=False, SaveFormsData:=False, _
        SaveAsAOCELetter:=False
This works fine as long as the date to which the document refers is the the same as the day on which I save it. However, if the document is received over the weekend and I save it on Monday, it is saved with the wrong date. I then have to go back into the folder and change the date.

What I really want to do is to open the "Save As" dialog box with the Save In box showing the folder in which the document is to be saved i.e "N:\Access\Houston Updates\Current Month" I can then give the saved document the correct date.

I have investigated "Dialogs(wdDialogFileSaveAs).Show" but I cannot find a way of specifying the folder that is opened.

Any advice would be much appreciated.

John
 
This is the Access VBA forum, isn't this Word? Perhaps forum707 would be better?

Anyway - try something like this:

[tt]dim dlg as dialog
set dlg=dialogs(wddialogfilesaveas)
with dlg
.name = "N:\Access\Houston Updates\Current Month\"
' which I think should set initial dir
if (.display = -1) then
msgbox .name ' and use this for further processing
end if
end with[/tt]

Roy-Vidar
 
This is only an idea.

Reference the outlook object.

Write a function that looks for a certain email header - once it finds it it detaches the attachment and uses the date of the mail in the file name - open the file and print it.

Have a look at creationtime and deferreddeliverytime as properties of the mail item in the outlook object.

I like being vague as you can have the "fun" of figuring out the answer from a few hints.

If at first you don't succeed, try for the answer.
 
Roy,

Thanks very much for the tip, it worked a treat. Sorry I put the question in the wrong forum.

GummowN,

Thanks for the thought, I have used Roy's method as it saved me precious time. I'll have a look at your idea when I have a few moments to spare.

Thanks to all

Best Regards
John
 
Roy,

I loaded this code and the correct folder opened. I then typed the name of the file into the box and pressed Save, and the message box opened up showing me tha name of the file I was saving. I pressed OK and the message box closed, but the file name was not saved.

I'm not sure what is going wrong, or why I need to see the message box at all.

Best Regards
John
 
Put the cursor inside the Dialogs word in your code and then press the F1 key.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Thanks PHV, that was very helpful. I have now changed the code to ".show" rather than the "if" statement and it worked fine.

Best Regards
John
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top