Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / June 2005

Tip: Looking for answers? Try searching our database.

Transforming adresses into full text

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
troubadour - 14 Jun 2005 16:49 GMT
I have a document (produced by mail merge from a ms-access  query),
containing many full paths of other documents (such as C:\mydoc\rose.doc).
The adresses are always between two # signs (#C:\mydoc\rose.doc#), and there
is no other # in the document for other purpose, i'm sure :-)

I would like to make a macro doing this : detecting each adress, then
opening the document with this file name, selecting the whole text of the
doc, copying it into the clipboard, closing the document, then pasting the
clipboard into the main document (and so on for each adress until the end of
the main document).
Is it reasonable ?
Who can help me (I’m a newby with VB, and not very good yet to modify the
code produced by a macro nor to debug)
Thank you
Toubadour
Anand.V.V.N - 15 Jun 2005 06:35 GMT
Hi troubadour,

You can do this in visual basic. By any chance you have used the string
manuplation in Visual Basic by the way?

Any way here is what you do. In a Visual Basic project, add reference to
Word 8.0, just check about this, it should be 8.0, though tis is not the
whole code, this is a basic code and will give you a overview as how the
program flows, I'll post the whole code

In a command button click event what you can do is use the

dim objword as word
dim cleanupstr as string

dim filetoopen as string

set objword=createobject("","Word.application")

Documents.Open filename confirmconversions:=True, Readonly:=True

With ActiveDocument.Content

' for each sentence in the document

   For i = 1 To .Sentences.Count

       
cleanupstr = .Sentences.Item(i)

   If Mid$(cleanupstr, 1, 1) = "#" Then
       filetoopen=mid$(cleanupstr,2,len(cleanupstr)-2)      
       
     Documents.Open filetoopen confirmconversions:=True, Readonly:=True
     ActiveDocument.Content.Copy
     activedocument.close          
     ActiveDocument.Content.InsertAfter Selection.Paste  

   Else
End If
Next i
End With

I am not sure about the pasting into the document though, insertafter or
insertmethod can be used to insert the content, I am not sure if
selection.paste works not not. Any way before you try on the actual documents
you can use this code on some test documents and try, to be on safe side.

Hope this code helps you.

Anand
Signature

"Who will guard the guards?"

> I have a document (produced by mail merge from a ms-access  query),
> containing many full paths of other documents (such as C:\mydoc\rose.doc).
[quoted text clipped - 11 lines]
> Thank you
> Toubadour
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.