Gasman
Enthusiastic Amateur
- Local time
 - Today, 08:21
 
- Joined
 - Sep 21, 2011
 
- Messages
 - 17,412
 
There was a thread recently where smart quotes were causing an issue?
I asked a good while back on an Excel forum, how to mailmerge excel data to a label sheet.
This code was supplied to me. I might have modified it for my case, but the smart quotes had to remain. In fact when I saw them, I immediately corrected them to single quote and then the code did not work.
	
	
	
		
So it seems, sometimes they do have their uses?
The smart quotes are in the SQLStatement line. They are ASC(96).
 I asked a good while back on an Excel forum, how to mailmerge excel data to a label sheet.
This code was supplied to me. I might have modified it for my case, but the smart quotes had to remain. In fact when I saw them, I immediately corrected them to single quote and then the code did not work.
		Code:
	
	
	    With wdDoc
        With .MailMerge
            .MainDocumentType = wdMailingLabels
            .OpenDataSource Name:=StrMMSrc, ReadOnly:=True, AddToRecentFiles:=False, _
                            LinkToSource:=False, Connection:="Provider=Microsoft.ACE.OLEDB.12.0;User ID=Admin;" & _
                                                             "Data Source=StrMMSrc;Mode=Read;Extended Properties=""HDR=YES;IMEX=1"";", _
                            SQLStatement:="SELECT * FROM `" & StrName & "$` WHERE Surname <> ''"
            .Execute Pause:=False
            .MainDocumentType = wdNotAMergeDocument
        End With
        '  .Close SaveChanges:=False
        ' Document has extra pages with empty labels, unable to find out why.
        'Save as PDF file
        strPDFName = "GCCS Passengers - " & StrName
        With wdApp.ActiveDocument
            .SaveAs Filename:=StrMMPath & strPDFName & ".pdf", FileFormat:=wdFormatPDF, AddToRecentFiles:=False
            .Close SaveChanges:=False
        End With
	The smart quotes are in the SQLStatement line. They are ASC(96).