Whenever I use the ActiveDocument.SaveAs2 command as below, it displays the conversion dialog (I am sure I did not get it before, i.e. it just saved the document). Can someone please shed some light on this as I would prefer to just save the document and get on with it without asking the user for conversion options?
BTW: The document being saved is opened as a blank document.
If bTestJobUpdates = True Then
' -------------------------------------- FOR TESTING ----------------------------------------------------
If MsgBox("TEST output created - save?", vbYesNo) = vbYes Then
ActiveDocument.SaveAs2 FileName:=sLocalFileName, FileFormat:=wdFormatText, LineEnding:=wdLFOnly
End If
Else
' -------------------------------------- FOR REAL -------------------------------------------------------
If MsgBox("Batch output ready - update?", vbYesNo) = vbYes Then
ActiveDocument.SaveAs2 FileName:=sSavedFilename, FileFormat:=wdFormatText, LineEnding:=wdLFOnly
End If
End If
Thanks.
You do not have the required permissions to view the files attached to this post.
Dim blnConfirm As Boolean
' Save setting
blnConfirm = Options.ConfirmConversions
' Turn confirm off
Options.ConfirmConversions = False
' Code to save document goes here
...
' Restore setting
Options.ConfirmConversions = blnConfirm
Dim blnConfirm As Boolean
' Save setting
blnConfirm = Options.ConfirmConversions
' Turn confirm off
Options.ConfirmConversions = False
' Code to save document goes here
...
' Restore setting
Options.ConfirmConversions = blnConfirm
Thanks Hans but no joy . It is still displaying the dialog. I even tried simply by opening a blank document and calling this function without all the checks so that it would just save the text documet but the result it exactly the same.
BTW: The ConfirmCoversions is already FALSE when we save the setting.
I moved the saving part in a separate function just to make sure it is kept simple.
Function SaveDocumentAsTextFile(ByRef tDoc As Document)
Dim blnConfirm As Boolean
' Save setting
blnConfirm = Options.ConfirmConversions
' Turn confirm off
Options.ConfirmConversions = False
If MsgBox("TEST output created - save?", vbYesNo) = vbYes Then
tDoc.SaveAs2 FileName:="C:\TextDocument.txt", FileFormat:=wdFormatText, LineEnding:=wdLFOnly
End If
' ----------------------------------------------------------------------------------------------------------
' Restore setting
Options.ConfirmConversions = blnConfirm
' Close the file without any changes (as it has been saved already)
tDoc.Close SaveChanges:=wdDoNotSaveChanges
End Function
I found something called Application.DisplayAlerts. If I switch that off then it *doesn't* display the dialog.
I don't know if it a good idea or not to switch of alerts before saving the document as text. Would it also switch of error messages (e.g. if the document could not be saved)?