![]() |
#5
|
|||
|
|||
![]()
This is driving me insane.
Code:
StrSQL = "SELECT * FROM [DATA$] WHERE [TYPE]='" & itype & "' AND [SIG_CREW]='" & isubresp & "' " & _ "ORDER BY [STARTS] ASC, [COMPLEX] ASC, [UNIT] ASC" Set objWord = CreateObject("Word.Application") With objWord .DisplayAlerts = False .Visible = True Set oDoc = .Documents.Open(Filename:=fName, ConfirmConversions:=False, _ ReadOnly:=True, AddToRecentFiles:=False, Visible:=True) With oDoc With .MailMerge .MainDocumentType = wdFormLetters .Destination = wdSendtToNewDocument .SuppressBlankLines = True .OpenDataSource Name:=StrSrc, AddToRecentFiles:=False, LinkToSource:=False, ConfirmConversions:=False, _ ReadOnly:=True, format:=wdOpenFormatAuto, Connection:="Provider=Microsoft.ACE.OLEDB.12.0;" & _ "User ID=Admin;Data Source=" & StrSrc & ";Mode=Read;Extended Properties=""HDR=YES;IMEX=1;"";", _ SQLStatement:=StrSQL, SQLStatement1:="", SubType:=wdMergeSubTypeAccess .Execute Pause:=False End With .Close False End With .DisplayAlerts = True 'page break routine only for sports reports If (Left(itype, 1) <> "G") And (itype <> "DT") Then 'exclude GS reports With .activedocument If .Sections.count > 1 Then For Each HdFt In .Sections(.Sections.count).Headers If HdFt.Exists Then HdFt.Range.FormattedText = .Sections(1).Headers(HdFt.index).Range.FormattedText HdFt.Range.Characters.Last.Delete End If Next For Each HdFt In .Sections(.Sections.count).Footers If HdFt.Exists Then HdFt.Range.FormattedText = .Sections(1).Footers(HdFt.index).Range.FormattedText HdFt.Range.Characters.Last.Delete End If Next End If Do While .Sections.count > 1 .Sections(1).Range.Characters.Last.Delete DoEvents Loop .Range.Characters.Last.Delete End With End If End With Set oDoc2 = objWord.activedocument 'save newly created document With oDoc2 myPath = "u:\PWS\Parks\Parks Operations\Sports\Sports17\WORKORDERS\" & format(ws_vh.Range("B17"), "ddd dd-mmm-yy") .SaveAs myPath & "\" & rpt_od & ".docx" If dest = 2 Then .PrintOut End If '.Close End With Set oDoc = Nothing: Set oDoc2 = Nothing ': Set objWord = Nothing Above is the code that is saving the merged documents. I have no problem creating or working with these reports at home. They create, save, can be opened, editted and resaved without any errors. The only think that sticks out as being unusual is "[Compatibility Mode]" If I take these same files on my thumbdrive to work, I can access the files but any edits cannot be saved. I am unable to open the documents from within my application, a feature of my excel application I have no issues with at home. |
Thread Tools | |
Display Modes | |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Excel to word Mail Merge problem | mark_kofi | Mail Merge | 4 | 07-17-2018 03:49 PM |
![]() |
drgt | Mail Merge | 2 | 02-14-2017 04:31 AM |
![]() |
Hook | Mail Merge | 2 | 01-11-2012 09:36 AM |
Mail Merge Problem | JohnRG | Mail Merge | 0 | 11-02-2009 02:50 AM |
problem in Mail merge | rjagathe | Mail Merge | 0 | 08-12-2009 08:25 AM |