Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #11  
Old 04-05-2013, 09:38 AM
JennEx JennEx is offline Problems With MergeField Switches Windows XP Problems With MergeField Switches Office 2003
Competent Performer
Problems With MergeField Switches
 
Join Date: May 2010
Posts: 162
JennEx is on a distinguished road
Default

All's not 100% yet as I'm finding myself running into some issues around this still.

When I use the mailmerge direct from Word, everything works fine. The file conversions check straightened out the date formatting problem I had.

However, the problem persists when I launch the Word mailmerge from VBA in my Excel application. My Excel VBA application allows the user to select which report she wishes to use.

The code below does everything it's supposed to do, however, the end result is the dates back into decimal format. The same report run direct from Word, and no problems.

Thoughts? Solutions?

Code:
Option Explicit
Dim objword As Object
Dim odoc As Object
Dim odoc2 As Object
Const wdsendtonewdocument = 0
Const wdsendtoprinter = 0
Dim mypath As String
Sub merge()
    Dim fname As String
    Set objword = CreateObject("Word.Application")
    objword.DisplayAlerts = True
    fname = "u:\Sports13\Reports\FR\v8\" & Worksheets("Front").Range("I14")
    Debug.Print fname
    Set odoc = objword.documents.Open(Filename:=fname, ConfirmConversions:=True, ReadOnly:=False, addtorecentfiles:=False)
    objword.Visible = True
    odoc.Application.Visible = True
    odoc.mailmerge.Destination = wdsendtonewdocument
    odoc.mailmerge.Execute
    Set odoc2 = odoc.Application.documents("Catalog1")
    odoc.Close False
    mypath = "u:\Sports13\Workorders\" & Format(Worksheets("varhold").Range("A1"), "ddd dd-mmm-yy")
    If Len(Dir(mypath, vbDirectory)) = 0 Then MkDir mypath
    odoc2.SaveAs mypath & "\" & (Worksheets("varhold").Range("A46").Value & "docx")
    objword.DisplayAlerts = True
    AppActivate "Microsoft Excel"
    Set objword = Nothing
    Set odoc = Nothing
    Set odoc2 = Nothing
End Sub
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Switches ilovemypuppy Word 2 02-08-2012 04:28 PM
Problems With MergeField Switches Index switches cksm4 Word VBA 2 02-03-2011 07:21 AM
Mail merge switches Jan Collier Mail Merge 0 08-29-2010 06:06 AM
Command Line Switches Ringmaster Office 0 08-10-2010 06:27 AM
Help with switches: Word mail merge with Excel ks_ Mail Merge 0 12-09-2009 05:09 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 06:03 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft