Jnickrand
Aug 29th, 2005, 12:47 PM
I was wondering if someone could help me tweak this code a little. This a macro in word that should save the document as a txt file with current filename that it has. The code below is saving all of the files into one notepad file called wrkord. Basically the word document gets open through a program and it gets assigned a number like (R792384750943875.rtf) When the user saves the document it saves it to a folder on the network where another program picks it up. All files should be separate, not all lumped together like they are now. THANKS :wave:
Public Sub HMSSave(Optional informUser As Boolean = True)
'variables added for brit
Dim wpathdoc As String
Dim wpathtx As String
Dim docToClose As String
Dim docToClose As String
Dim foundstring As Long
Dim britpathtxt As String
Dim tempvar As String
'end of variables
'save a version for brit teleradiology
If ActiveDocument.Name Like "*_temp.doc" Then
System.Cursor = wdCursorWait
wpathdoc = ActiveDocument.Variables("wpathdocvar").Value
wpathtxt = ActiveDocument.Variables("wpathtxtvar").Value
foundstring = InStr(1, wpathtxt, "\")
tempvar = wpathtxt
While foundstring <> 0
tempvar = Mid(tempvar, foundstring + 1)
foundstring = InStr(foundstring, tempvar, "\")
Wend
'end of brit code
ActiveDocument.save 'saves the doc as "app_path + \temp.doc"
On Error Resume Next
Kill wpathdoc
Kill wpathtxt
' New for brit
Kill britpathtxt
' End
On Error GoTo 0
' store the name of the current document
docToOpen = ActiveDocument.FullName
' createtextfile (APP_PATH + "\temp.txt")
ActiveDocument.SaveAs FileName:=wpathtxt, fileformat:=wdFormatDOSTextLineBreaks
'Save a txt copy for brit teleradiology
britpathtxt = "I:\brit\" & ActiveDocument.Name
ActiveDocument.SaveAs fileName:=britpathtxt, fileformat:=wdFormatDOSTextLineBreaks
'end
'get the current name of the doc
docToClose = ActiveDocument.Name
're-open temp.doc for more editing
Documents.Open docToOpen
'Close the other doc
Document(docToClose).Close
If informUser = true then
MsgBox “Document saved.”, vbOKOnly + vbInformation, “HMS Trans”
End if
=============================================================This is the new code that they have in the Macro
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
ActiveDocument.save
If informUser = True Then
If getType() = TYPE_DOCUMENT Then
VBA.MsgBox "Transcription document saved.", vbOKOnly + vbInformation, "HMS Transcription"
Else
VBA.MsgBox "Transcription template saved.", vbOKOnly + vbInformation, "HMS Transcription"
End If
End If
End Sub
Public Sub HMSSave(Optional informUser As Boolean = True)
'variables added for brit
Dim wpathdoc As String
Dim wpathtx As String
Dim docToClose As String
Dim docToClose As String
Dim foundstring As Long
Dim britpathtxt As String
Dim tempvar As String
'end of variables
'save a version for brit teleradiology
If ActiveDocument.Name Like "*_temp.doc" Then
System.Cursor = wdCursorWait
wpathdoc = ActiveDocument.Variables("wpathdocvar").Value
wpathtxt = ActiveDocument.Variables("wpathtxtvar").Value
foundstring = InStr(1, wpathtxt, "\")
tempvar = wpathtxt
While foundstring <> 0
tempvar = Mid(tempvar, foundstring + 1)
foundstring = InStr(foundstring, tempvar, "\")
Wend
'end of brit code
ActiveDocument.save 'saves the doc as "app_path + \temp.doc"
On Error Resume Next
Kill wpathdoc
Kill wpathtxt
' New for brit
Kill britpathtxt
' End
On Error GoTo 0
' store the name of the current document
docToOpen = ActiveDocument.FullName
' createtextfile (APP_PATH + "\temp.txt")
ActiveDocument.SaveAs FileName:=wpathtxt, fileformat:=wdFormatDOSTextLineBreaks
'Save a txt copy for brit teleradiology
britpathtxt = "I:\brit\" & ActiveDocument.Name
ActiveDocument.SaveAs fileName:=britpathtxt, fileformat:=wdFormatDOSTextLineBreaks
'end
'get the current name of the doc
docToClose = ActiveDocument.Name
're-open temp.doc for more editing
Documents.Open docToOpen
'Close the other doc
Document(docToClose).Close
If informUser = true then
MsgBox “Document saved.”, vbOKOnly + vbInformation, “HMS Trans”
End if
=============================================================This is the new code that they have in the Macro
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
ActiveDocument.save
If informUser = True Then
If getType() = TYPE_DOCUMENT Then
VBA.MsgBox "Transcription document saved.", vbOKOnly + vbInformation, "HMS Transcription"
Else
VBA.MsgBox "Transcription template saved.", vbOKOnly + vbInformation, "HMS Transcription"
End If
End If
End Sub