Web Development
8 replies
by peyison
You could create a VBA routine to close the document. Something like:
Public Sub CloseOrig()
'--replace MyDoc.doc with the name of your document
With Application.Documents("MyDoc.doc")
'--set the saved flag so Word won't ask if you want tosave first
.Saved = True
.Close
End With
End Sub
You can also use a more generic version:
Public Sub CloseOrig(asDocName as String)
With Application.Documents(asDocName)
.Saved = True
.Close
End With
End Sub
Hope this helps.
by bytemi
The 1st script did not run properly, when I entered my document name it told me that it did not exist. I tried entering the full path but that did not work either. So I tried the bottom one and it worked, but it closed the new document instead of the original document.
This is what I came up with yesturday after posting my question. The problems is it does not go back to the orignial document it just picks a window and closes it.
Sub CloseSource()
ActiveWindow.Previous.Activate ActiveDocument.Close (wdDoNotSaveChanges)
End Sub
I really appreciate your help, thank you.
by andersos
You could save the document using saveas.
Example:
ActiveDocument.SaveAs FileName:="Text.rtf", FileFormat:=wdFormatRTF
See saveas in the microsoft word visual basic help file. I use this command in access with excel documents quite often.
by bytemi
by wayne m.
by bytemi
by bytemi
Here is the answer. Please feel free to use this code if you need it. If you have any question feel free to e-mail me.
' This line needs to be entered when the source document is Opened
Set objSrcDoc = ActiveDocument
' This line needs to be entered after the documents are merged.
Set objDstDoc = ActiveDocument
' This will close the source document
objSrcDoc.Close savechanges:=wdDoNotSaveChanges
by bytemi
This discussion is closed to new replies.
Trending Web Development posts
Sort by Trending