Kilroy
07-15-2019, 01:41 PM
Is it possible to:
1. open a document using a dialog box
2. save the document with the same name but use .xml extension
3. open the new .xml document in wordpad
4. do a find and replace
5. save
this is what I have so far:
Sub PickAndProcess()
Dim intChoice As Integer
Dim strPath As String
Dim objWord As Object
Set objWord = CreateObject("Word.Application")
objWord.Visible = True
Application.FileDialog(msoFileDialogOpen).AllowMultiSelect = False
intChoice = Application.FileDialog(msoFileDialogOpen).Show
If intChoice <> 0 Then
strPath = Application.FileDialog( _
msoFileDialogOpen).SelectedItems(1)
End If
Dim doc As Document
Set doc = Documents.Open(strPath)
With doc
Dim strDocName As String
Dim intPos As Integer
strDocName = ActiveDocument.Name
intPos = InStrRev(strDocName, ".")
strDocName = Left(strDocName, intPos - 1)
strDocName = strDocName & ".xml"
ActiveDocument.SaveAs2 FileName:=strDocName, _
FileFormat:=wdFormatXML
End With
ActiveDocument.Close
'oDoc = strDocName????
'With oDoc
'Open with notepad
'find text
'replace text
'save
'close
'End With
'open xml document
'save as .docx
End Sub
1. open a document using a dialog box
2. save the document with the same name but use .xml extension
3. open the new .xml document in wordpad
4. do a find and replace
5. save
this is what I have so far:
Sub PickAndProcess()
Dim intChoice As Integer
Dim strPath As String
Dim objWord As Object
Set objWord = CreateObject("Word.Application")
objWord.Visible = True
Application.FileDialog(msoFileDialogOpen).AllowMultiSelect = False
intChoice = Application.FileDialog(msoFileDialogOpen).Show
If intChoice <> 0 Then
strPath = Application.FileDialog( _
msoFileDialogOpen).SelectedItems(1)
End If
Dim doc As Document
Set doc = Documents.Open(strPath)
With doc
Dim strDocName As String
Dim intPos As Integer
strDocName = ActiveDocument.Name
intPos = InStrRev(strDocName, ".")
strDocName = Left(strDocName, intPos - 1)
strDocName = strDocName & ".xml"
ActiveDocument.SaveAs2 FileName:=strDocName, _
FileFormat:=wdFormatXML
End With
ActiveDocument.Close
'oDoc = strDocName????
'With oDoc
'Open with notepad
'find text
'replace text
'save
'close
'End With
'open xml document
'save as .docx
End Sub