Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Newsgroup Archive
Word Newsgroups
Word Mail Merge
WORD Mailmerge with Excel DataSource - loss of formatting
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
Reply to thread
Message
[QUOTE="Peter Jamieson, post: 5600748"] Hi Bob, Yes, it is sometimes difficult to see any pattern in situations like this, particularly with a product like Excel where the formatting of a cell may affect how Word sees the data. There's an example at [URL]http://word.mvps.org/FAQs/InterDev/ControlWordFromXL.htm[/URL] . Derived from that you need something like the following (not tested). Sub ControlWordFromXL() Dim bWordWasNotRunning As Boolean Dim objWord As Word.Application Dim objDoc As Word.Document 'Get existing instance of Word if it's open; otherwise create a new one On Error Resume Next Set objWord = GetObject(, "Word.Application") If Err Then Set objWord = New Word.Application bWordWasNotRunning = True End If On Error GoTo Err_Handler objWord.Visible = True objWord.Activate Set objDoc = objWord.Documents.Open _ Name:="the full path name of the .doc you want to open" Set objWord = Nothing Set objDoc = Nothing 'quit Exit Sub Err_Handler: MsgBox "Word caused a problem. " & Err.Description, vbCritical, "Error: " _ & Err.Number If bWordWasNotRunning Then objWord.Quit End If End Sub [/QUOTE]
Verification
Post reply
Forums
Archive
Newsgroup Archive
Word Newsgroups
Word Mail Merge
WORD Mailmerge with Excel DataSource - loss of formatting
Top