Jump to content

Macro help


Recommended Posts

I need to save my word documents to a folder on our network. Currently we have a macro called HMSSave.

Im not sure what code I need to add to this macro in order to save the word document into a folder (ORYX) on our network.


Public Sub HMSSave(Optional informUser As Boolean = True)

shouldBeMoved = True

'Make sure to update all built in document properties.

ActiveDocument.ComputeStatistics wdStatisticCharacters

ActiveDocument.ComputeStatistics wdStatisticCharactersWithSpaces

ActiveDocument.ComputeStatistics wdStatisticLines

ActiveDocument.ComputeStatistics wdStatisticPages

ActiveDocument.ComputeStatistics wdStatisticWords


If informUser = True Then

If getType() = TYPE_DOCUMENT Then

VBA.MsgBox "Transcription document saved.", vbOKOnly + vbInformation, "HMS Transcription"


VBA.MsgBox "Transcription template saved.", vbOKOnly + vbInformation, "HMS Transcription"

End If

End If

End Sub

Edited by jnickrand
Link to comment
Share on other sites

  • 1 month later...

I'm not sure what kind of options you are looking to add, but the following is a quick example of how to do this.

Set up a couple of variables, strDocName and strDirectory. The code below simply sets the strDocName variable to be the current file name. The strDirectory variable is currently set to the Temp directory on your hard drive. This is the place where you can enter in the new directory path you want the file to save to. Notice that the directory variable includes the trailing backslash (this is important).

*------------Begin Code Snippit-------------*

Dim strDocName as String

Dim strDirectory as String

strDocName = ActiveDocument.Name

strDirectory = "C:\Temp\"

ActiveDocument.SaveAs FileName:=strDirectory & strDocName, FileFormat:=wdFormatDocument

*------------End Code Snippit --------------*

You can look in the VBA Help files for a detailed description of the SaveAs function options (there are a lot). However, you most likely won't need any of them for this instance. The code above simply states that the file should be saved in "C:\Temp\" as a word document (not as RTF, or plain text, HTML, etc.)

In case you're new to VBA, the 'strDirectory & strDocName' piece above is a quick way of craming two strings (ie text fields) together. Say your file was named "MyFile.doc". The code above sets the FileName variable in the SaveAs function to "C:\Temp\MyFile.doc".

Hope this helps...


Link to comment
Share on other sites

  • 2 months later...

Take a look at Options.(so in a vba app type the words OPTIONS and then FULL STOP under the AUTOOPEN and AUTONEW macros) then set the default path to your network drive, then when a user saves / saves as it will coem up with the correct folder / drive.

does that make sence?



Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    • No registered users viewing this page.

  • Create New...