Chief Gopher
03-23-2010, 09:00 AM
I have a file which runs from a macro. The code includes ConfirmConversion=False to suppress the file conversion box, but I need it to specify that the file conversion should be the windows default.
For some strange reason, I am unable to ascertain why, it takes 1 in every 1000 documents and converts them as Japanese (Shift JIS) rather than the required Western European (Windows). This results in all the £ in the document (an invoice) to show as a backwards L
Is there a code in vba where I can still suppress the file conversion box, but select the windows default.
The original sub is
Sub sinv()
WordBasic.AppMinimize
Selection.InsertFile FileName:=Environ("temp") & "\sinv.txt", Range:="", ConfirmConversions:= _
False, Link:=False, Attachment:=False
WordBasic.EditSelectAll
WordBasic.Style "sinvoice"
Call check_ams
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "#"
.Replacement.Text = "£"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
WordBasic.EndofDocument
WordBasic.EditClear -1
Application.PrintOut FileName:="", Range:=wdPrintAllDocument, Item:= _
wdPrintDocumentContent, Copies:=1, Pages:="", PageType:=wdPrintAllPages, _
Collate:=True, Background:=False, PrintToFile:=False
Application.Quit (wdDoNotSaveChanges)
End Sub
this sub sinv calls a multiple macros (I have only shown one) to show which item in the extract file corresponds to which field on the document ie....
Sub check_ams()
If Selection.Find.Execute("@@@@@AMS") = True Then
ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
Selection.HeaderFooter.Shapes("Text Box 18").Select
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "ADD1"
.Replacement.Text = "Corporation"
.Forward = False
.Wrap = wdFindContinue
.Format = False
.MatchCase = True
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
With Selection.Find
.Text = "ADD2"
.Replacement.Text = "Cornwall"
.Forward = False
.Wrap = wdFindContinue
.Format = False
.MatchCase = True
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
With Selection.Find
.Text = "ADD3"
.Replacement.Text = "Cornwall. "
.Forward = False
.Wrap = wdFindContinue
.Format = False
.MatchCase = True
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
With Selection.Find
.Text = "ADD4"
.Replacement.Text = "Tel : () Fax : ()"
.Forward = False
.Wrap = wdFindContinue
.Format = False
.MatchCase = True
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
With Selection.Find
.Text = "ADD5"
.Replacement.Text = "VAT Number : nn nnnn nnn"
.Forward = False
.Wrap = wdFindContinue
.Format = False
.MatchCase = True
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageFooter
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "ADD6"
.Replacement.Text = "Payment Details: You can pay by debit/credit card "
.Forward = False
.Wrap = wdFindContinue
.Format = False
.MatchCase = True
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
With Selection.Find
.Text = "ADD7"
.Replacement.Text = "Alternatively send a cheque made payable to ...."
.Forward = False
.Wrap = wdFindContinue
.Format = False
.MatchCase = True
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "@@@@@AMS"
.Replacement.Text = ""
.Forward = False
.Wrap = wdFindContinue
.Format = False
.MatchCase = True
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
End If
End Sub
For some strange reason, I am unable to ascertain why, it takes 1 in every 1000 documents and converts them as Japanese (Shift JIS) rather than the required Western European (Windows). This results in all the £ in the document (an invoice) to show as a backwards L
Is there a code in vba where I can still suppress the file conversion box, but select the windows default.
The original sub is
Sub sinv()
WordBasic.AppMinimize
Selection.InsertFile FileName:=Environ("temp") & "\sinv.txt", Range:="", ConfirmConversions:= _
False, Link:=False, Attachment:=False
WordBasic.EditSelectAll
WordBasic.Style "sinvoice"
Call check_ams
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "#"
.Replacement.Text = "£"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
WordBasic.EndofDocument
WordBasic.EditClear -1
Application.PrintOut FileName:="", Range:=wdPrintAllDocument, Item:= _
wdPrintDocumentContent, Copies:=1, Pages:="", PageType:=wdPrintAllPages, _
Collate:=True, Background:=False, PrintToFile:=False
Application.Quit (wdDoNotSaveChanges)
End Sub
this sub sinv calls a multiple macros (I have only shown one) to show which item in the extract file corresponds to which field on the document ie....
Sub check_ams()
If Selection.Find.Execute("@@@@@AMS") = True Then
ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
Selection.HeaderFooter.Shapes("Text Box 18").Select
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "ADD1"
.Replacement.Text = "Corporation"
.Forward = False
.Wrap = wdFindContinue
.Format = False
.MatchCase = True
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
With Selection.Find
.Text = "ADD2"
.Replacement.Text = "Cornwall"
.Forward = False
.Wrap = wdFindContinue
.Format = False
.MatchCase = True
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
With Selection.Find
.Text = "ADD3"
.Replacement.Text = "Cornwall. "
.Forward = False
.Wrap = wdFindContinue
.Format = False
.MatchCase = True
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
With Selection.Find
.Text = "ADD4"
.Replacement.Text = "Tel : () Fax : ()"
.Forward = False
.Wrap = wdFindContinue
.Format = False
.MatchCase = True
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
With Selection.Find
.Text = "ADD5"
.Replacement.Text = "VAT Number : nn nnnn nnn"
.Forward = False
.Wrap = wdFindContinue
.Format = False
.MatchCase = True
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageFooter
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "ADD6"
.Replacement.Text = "Payment Details: You can pay by debit/credit card "
.Forward = False
.Wrap = wdFindContinue
.Format = False
.MatchCase = True
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
With Selection.Find
.Text = "ADD7"
.Replacement.Text = "Alternatively send a cheque made payable to ...."
.Forward = False
.Wrap = wdFindContinue
.Format = False
.MatchCase = True
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "@@@@@AMS"
.Replacement.Text = ""
.Forward = False
.Wrap = wdFindContinue
.Format = False
.MatchCase = True
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
End If
End Sub