Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Word Macro - User Input required 1

Status
Not open for further replies.

colinmitton

Technical User
Feb 24, 2005
190
GB
I have recorded a macro to insert text to a part of a document, It effective finds a particular set of text in the document and inserts a word document in the place. As shown here :

Sub text1()
'
' text1 Macro
'
Selection.Find.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
Selection.InsertFile FileName:="Test.doc", Range:="", ConfirmConversions:= _
False, Link:=False, Attachment:=False
End Sub


The Next step for me is to have the user select the file to insert instead of me having to right a macro for each document! Could anyone help please.

Thanks

Colin
 
No, I really just need to run the 'insertfile' dialog windows as the users will be selecting documents from various locations. So when they click ok the text is inserted where the 'find' has finished.

I hope this makes sense!

Colin
 
Ahh... Just found out how!

Dialogs(wdDialogInsertFile).Show

works fine now.

Thanks for you time Gerry.
 
Code:
With Selection.Find
   .ClearFormatting
   .Text = "***"
   .Replacement.Text = ""
   .Forward = True
   .Execute
End With
Application.Dialogs(wdDialogInsertFile).Show
Whatever file they select, and click Insert, will be inserted at the Selection.


faq219-2884

Gerry
My paintings and sculpture
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top