View Single Post
  #7   Report Post  
Murray Muspratt-Rouse Murray Muspratt-Rouse is offline
Member
 
Location: Mill Hill, London, England
Posts: 44
Default

I have made some changes -
Dim intSplitName As Integer
Dim intLength As Integer
intLength = Len(strDocName)
intSplitName = InStrRev(strDocName, "\", , vbTextCompare)
strDocName = Right(strDocName, intLength - intSplitName)


'objApp.Windows(strDocName).Activate
objApp.strDocName.Close SaveChanges:=wdDoNotSaveChanges




'objApp.Documents.Open strDocName


objApp.Visible = True
objApp.Activate

The result has been, with the example I chose to test, that the first of 3 merged letters was displayed. When I closed it I then found myself looking at the original document again, from which I could run the merge and see all 3 letters!

The plot thickens!

Murray


Quote:
Originally Posted by Murray Muspratt-Rouse View Post
I agree with Doug about the code he does not understand - since I am not the original author of this code and do not speak VBA any way I have been struggling to find my way to add new function to the application.

The merge document is selected by the user from an Access table in which the full path to the file is stored, so what the code that we cannot understand does is to strip off the path to the document from strDocName: -
Dim intSplitName As Integer
Dim intLength As Integer
intLength = Len(strDocName)
intSplitName = InStrRev(strDocName, "\", , vbTextCompare)
strDocName = Right(strDocName, intLength - intSplitName)


objApp.Windows(strDocName).Activate
objApp.ActiveWindow.Close SaveChanges:=wdDoNotSaveChanges
So perhaps what the last line does is to shut the new document, since the original merge document is displayed. I have tried commenting out this code but that only results in an error. I will try changing ActiveWindow in the last line to strDocName!

Many thanks for your time and trouble

Murray