Private WordServer As Word.Application
Private Sub Command1_Click()
Dim file_name As String
Dim file_path As String
Dim file_title As String
Dim txt As String
Dim new_txt As String
Dim pos As Integer
Screen.MousePointer = vbHourglass
Command1.Enabled = False
DoEvents
' Open Word.
file_name = txtFilename.Text
file_title = Mid$(file_name, InStrRev(file_name, "\") + _
1)
file_path = Left$(file_name, Len(file_name) - _
Len(file_title))
' Uncomment to show Word.
' WordServer.Visible = True
WordServer.ChangeFileOpenDirectory file_path
WordServer.Documents.Open _
FileName:=file_title, _
ConfirmConversions:=False, _
ReadOnly:=False, _
AddToRecentFiles:=False, _
PasswordDocument:="", _
PasswordTemplate:="", _
Revert:=False, _
WritePasswordDocument:="", _
WritePasswordTemplate:="", _
Format:=wdOpenFormatAuto
' Go to the bookmark.
WordServer.Selection.GoTo _
What:=wdGoToBookmark, _
Name:="Disclaimer"
WordServer.Selection.Find.ClearFormatting
With WordServer.Selection.Find
.Text = ""
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
' Copy the image to the clipboard.
Clipboard.Clear
Clipboard.SetData Picture1.Picture, vbCFBitmap
' Paste the image into Word.
WordServer.Selection.Paste
' Comment out to keep Word running.
WordServer.Quit True
Set WordServer = Nothing
Screen.MousePointer = vbDefault
Command1.Enabled = True
End Sub
|