Results 1 to 6 of 6

Thread: New program broke our code

Threaded View

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Aug 2005
    Posts
    20

    New program broke our code

    The problem that I am having is that a company came in and did some upgrades to our system. We some macros in Microsoft word that saved the file out to a folder on our network but with the new code it does not do that anymore. Could someone help me tweak the code so that it will save the file out to the network folder? (Thanks)

    Here is the code in our old macro that worked.
    VB Code:
    1. Public Sub HMSSave(Optional informUser As Boolean = True)
    2.  
    3.     'variables added for brit
    4.     Dim wpathdoc As String
    5.     Dim wpathtx As String
    6.     Dim docToClose As String
    7.     Dim docToClose As String
    8.     Dim foundstring As Long
    9.     Dim britpathtxt As String
    10.     Dim tempvar As String
    11.     'end of variables
    12.    
    13.     'save a version for brit teleradiology
    14.     If ActiveDocument.Name Like "*_temp.doc" Then
    15.         System.Cursor = wdCursorWait
    16.         wpathdoc = ActiveDocument.Variables("wpathdocvar").Value
    17.         wpathtxt = ActiveDocument.Variables("wpathtxtvar").Value
    18.            
    19.     foundstring = InStr(1, wpathtxt, "\")
    20.     tempvar = wpathtxt
    21.     While foundstring <> 0
    22.         tempvar = Mid(tempvar, foundstring + 1)
    23.         foundstring = InStr(foundstring, tempvar, "\")
    24.     Wend
    25.     'end of brit code
    26.    
    27.     ActiveDocument.save  'saves the doc as "app_path + \temp.doc"
    28.     On Error Resume Next
    29.     Kill wpathdoc
    30.     Kill wpathtxt
    31.    
    32.     ' New for brit
    33.     Kill britpathtxt
    34.     ' End
    35.    
    36.     On Error GoTo 0
    37.     ' store the name of the current document
    38.     docToOpen = ActiveDocument.FullName
    39.     ' createtextfile (APP_PATH + "\temp.txt")
    40.     ActiveDocument.SaveAs FileName:=wpathtxt, fileformat:=wdFormatDOSTextLineBreaks
    41.     'Save a txt copy for brit teleradiology
    42.     britpathtxt = "I:\brit\" & ActiveDocument.Name
    43.     'end
    44.     'get the current name of the doc
    45.     docToClose = ActiveDocument.Name
    46.     're-open temp.doc for more editing
    47.     Documents.Open docToOpen
    48.     'Close the other doc
    49.     Document(docToClose).Close
    50.        
    51. If informUser = true then
    52. MsgBox “Document saved.”, vbOKOnly + vbInformation, “HMS Trans”
    53. End if  
    54. =============================================================This is the new code that they have in the Macro
    55.  
    56. Public Sub HMSSave(Optional informUser As Boolean = True)
    57.   shouldBeMoved = True
    58.   'Make sure to update all built in document properties.
    59.   ActiveDocument.ComputeStatistics wdStatisticCharacters
    60.   ActiveDocument.ComputeStatistics wdStatisticCharactersWithSpaces
    61.   ActiveDocument.ComputeStatistics wdStatisticLines
    62.   ActiveDocument.ComputeStatistics wdStatisticPages
    63.   ActiveDocument.ComputeStatistics wdStatisticWords
    64.  
    65.   ActiveDocument.save
    66.  
    67.   If informUser = True Then
    68.     If getType() = TYPE_DOCUMENT Then
    69.       VBA.MsgBox "Transcription document saved.", vbOKOnly + vbInformation, "HMS Transcription"
    70.     Else
    71.       VBA.MsgBox "Transcription template saved.", vbOKOnly + vbInformation, "HMS Transcription"
    72.     End If
    73.   End If
    74.  
    75. End Sub

    I added the old code to the first part of the new code and when I saved the document it saved without any errors. However it did not save a copy of the document to the network drive. Please help!!!!!!!! Thanks.





    Edit: Added [vbcode][/vbcode] tags for clairty. - Hack
    Last edited by Hack; Aug 26th, 2005 at 08:14 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width