Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / July 2005

Tip: Looking for answers? Try searching our database.

Save to Network

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Help with Macro - 18 Feb 2004 14:46 GMT
Hey Gang,
I am assisting individuals with developing their resumes
using Word Resume Templates.  There could be up to 20
students with a wide range of computer experience.  The
students are given a disk to save & keep a copy of their
completed resume.  I also need a copy of their resume.

I need a macro that will:
1.  Use the file name already assigned to the document.  
(It will be a unique name).
2.  Save the file to a network location: P/cisco/resume
3.  Again save the document 'A' drive
4.  End the macro.

Your help appreciated - Thanks,
Jerry
Peter Hewett - 19 Feb 2004 01:56 GMT
Hi Jerry

Rather than use Words save method, use the SaveAs, something like this:

Public Sub SaveDocTwice()
   Const cAPath As String = "A:\"
   Const cNetWorkPath As String = "F:\"

   Dim strOriginalFullPath As String
   Dim strOriginalPath As String

   With ActiveDocument
       
       ' Before we do anything make sure that
       ' the current document has been
       ' previously saved and is saved to one of the two permisable paths
       strOriginalFullPath = .FullName
       strOriginalPath = .Path & "\"
       If Len(.Path) = 0 Then
           MsgBox "The document must have been previously" & _
             " saved as it has no name"
           Exit Sub
       End If
       If StrComp(strOriginalPath, cAPath, vbTextCompare) <> 0 And _
         StrComp(strOriginalPath, cNetWorkPath, vbTextCompare) <> 0 Then
           MsgBox "You cannot save the current document it " & _
             " does not use an expected path: " & strOriginalPath
           Exit Sub
       End If

         ' keep it smooth for the user
       Application.ScreenUpdating = False

       ' Do it this way so it doesn't matter which document we're using
       .SaveAs "C:\" & .Name
       .SaveAs "F:\" & .Name

       ' If the current document is not the original one
       ' then close this one and reopen the original
       If .Path & "\" <> strOriginalPath Then
           .Close wdDoNotSaveChanges
           Documents.Open strOriginalFullPath
       End If
       Application.ScreenUpdating = True
   End With
End Sub

This code checks that the document you are saving has been previously
saved, because if it hasn't then it doesn't have a name! It then checks
that the docuemnt has been saved to one of the 2 permisable paths, this
ensures that it's one of the documents you want saved twice and not another
Word document someone is working on.

It then saves the file twice to the two locations and then reopens the file
that was originally open if necessary. This was you can work with either of
the 2 documents and they will both save correctly and the original file
will still be open when the code completes!

Just edit the Const statements in the above code to reflect the actual
paths you want to use. MAKE SURE that the paths terminate with a "\"
character.

HTH + Cheers - Peter

"Help with Macro" <Jerry.Lauzon@blinn.edu> wrote in news:129d501c3f62d
$f478bb20$a501280a@phx.gbl:

> Hey Gang,
> I am assisting individuals with developing their resumes
[quoted text clipped - 12 lines]
> Your help appreciated - Thanks,
> Jerry
richardall - 14 Jul 2005 21:01 GMT
I am looking for something very similar.

I need a piece of code that can be used in a form.  I would like to
trigger a macro after the last field is completed.  I would use the on
exit for this.

I would like a macro that would bring up the save dialog box and
automatically fill in a name based on a date.  For example the file name
might be "form_yyyymmdd".

I see in this code you suggest that a path is predetermined, I could maybe
use this but would like the flexibility to use the save dialog to browse my
way to the needed location.

Any suggestions?  Can you also remark the code well, I'm trying to learn
the VB and it would really help me.

Any help would be appreciated.

Richard
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.