Discussion:
How to use printer name having double quotes
(too old to reply)
DPM
2010-04-19 04:48:48 UTC
Permalink
Hi,

ShellExcute is used to print to a given printer as follows from VFP9.

DECLARE LONG ShellExecute IN "shell32.dll" LONG nHandle, STRING cOperation,
STRING cFile, ;
STRING vParameters, STRING cDirectory, LONG nShowCmd

lnSuccess = ShellExecute(0, "PRINTTO", "C:\Test.Txt", '"Printer Name"', "",
1)

This works fine.
But the problem is when the name of the printer has a double quote("), it
does not print.

The following does not work.
eg. Assume the name of the printer is '"Printer "Name"' as the parameter
passed into ShellExecute()
=> Using 2 or 3 double quotes("") to represent a single double quote("). eg.
'"Printer ""Name"' or '"Printer """Name"'
=> Using slash and double quote(\") to represent a single double quote(").
eg. '"Printer \"Name"'

Could someone please advice what could be done to support printers with a
double quote in its name.
Villi Bernaroli
2010-04-19 06:54:50 UTC
Permalink
Post by DPM
Hi,
ShellExcute is used to print to a given printer as follows from VFP9.
DECLARE LONG ShellExecute IN "shell32.dll" LONG nHandle, STRING
cOperation, STRING cFile, ;
STRING vParameters, STRING cDirectory, LONG nShowCmd
lnSuccess = ShellExecute(0, "PRINTTO", "C:\Test.Txt", '"Printer
Name"', "", 1)
This works fine.
But the problem is when the name of the printer has a double
quote("), it does not print.
The following does not work.
eg. Assume the name of the printer is '"Printer "Name"' as the
parameter passed into ShellExecute()
=> Using 2 or 3 double quotes("") to represent a single double
quote("). eg. '"Printer ""Name"' or '"Printer """Name"'
=> Using slash and double quote(\") to represent a single double
quote("). eg. '"Printer \"Name"'
Could someone please advice what could be done to support printers
with a double quote in its name.
Did you try using the square brackets as string delimiters? Like this:
["Printer "Name"]

BTW it's strange that the printer's name contains an uneven number of double
quotes.
It would be more logical to use a even number, as in 'Printer "Name"'.
--
Villi Bernaroli, Italy
VFP, SOAP, MS SQLserver, MySQL, Oracle
DPM
2010-04-19 08:57:33 UTC
Permalink
Hi, Villi,

Specifying the printer name as follows also does not work.
["Printer "Name"]

If the printer name has a odd number or even number of double quotes still
cannot print to it.

Any other alternatives?
Post by Villi Bernaroli
Post by DPM
Hi,
ShellExcute is used to print to a given printer as follows from VFP9.
DECLARE LONG ShellExecute IN "shell32.dll" LONG nHandle, STRING
cOperation, STRING cFile, ;
STRING vParameters, STRING cDirectory, LONG nShowCmd
lnSuccess = ShellExecute(0, "PRINTTO", "C:\Test.Txt", '"Printer
Name"', "", 1)
This works fine.
But the problem is when the name of the printer has a double
quote("), it does not print.
The following does not work.
eg. Assume the name of the printer is '"Printer "Name"' as the
parameter passed into ShellExecute()
=> Using 2 or 3 double quotes("") to represent a single double
quote("). eg. '"Printer ""Name"' or '"Printer """Name"'
=> Using slash and double quote(\") to represent a single double
quote("). eg. '"Printer \"Name"'
Could someone please advice what could be done to support printers
with a double quote in its name.
["Printer "Name"]
BTW it's strange that the printer's name contains an uneven number of
double quotes.
It would be more logical to use a even number, as in 'Printer "Name"'.
--
Villi Bernaroli, Italy
VFP, SOAP, MS SQLserver, MySQL, Oracle
Jan Bucek
2010-04-19 09:18:18 UTC
Permalink
Post by DPM
Hi, Villi,
Specifying the printer name as follows also does not work.
["Printer "Name"]
If the printer name has a odd number or even number of double quotes still
cannot print to it.
Any other alternatives?
1. rename the printer

2. try to use variable
store ["Printer Name"] to lcPrinterName
lnSuccess = ShellExecute(0, "PRINTTO", "C:\Test.Txt", lcPrintername, "", 1)
Post by DPM
Post by Villi Bernaroli
Post by DPM
Hi,
ShellExcute is used to print to a given printer as follows from VFP9.
DECLARE LONG ShellExecute IN "shell32.dll" LONG nHandle, STRING
cOperation, STRING cFile, ;
STRING vParameters, STRING cDirectory, LONG nShowCmd
lnSuccess = ShellExecute(0, "PRINTTO", "C:\Test.Txt", '"Printer
Name"', "", 1)
This works fine.
But the problem is when the name of the printer has a double
quote("), it does not print.
The following does not work.
eg. Assume the name of the printer is '"Printer "Name"' as the
parameter passed into ShellExecute()
=> Using 2 or 3 double quotes("") to represent a single double
quote("). eg. '"Printer ""Name"' or '"Printer """Name"'
=> Using slash and double quote(\") to represent a single double
quote("). eg. '"Printer \"Name"'
Could someone please advice what could be done to support printers
with a double quote in its name.
["Printer "Name"]
BTW it's strange that the printer's name contains an uneven number of
double quotes.
It would be more logical to use a even number, as in 'Printer "Name"'.
--
Villi Bernaroli, Italy
VFP, SOAP, MS SQLserver, MySQL, Oracle
DPM
2010-04-19 11:30:54 UTC
Permalink
Hi Jan,

Required user access is needed to rename a printer.
Specially network printers cannot be renamed unless user access is granted.
Also, renaming the printer may not be suitable in a multiuser enviroment.

Any other suggestions?
Post by Jan Bucek
Post by DPM
Hi, Villi,
Specifying the printer name as follows also does not work.
["Printer "Name"]
If the printer name has a odd number or even number of double quotes still
cannot print to it.
Any other alternatives?
1. rename the printer
2. try to use variable
store ["Printer Name"] to lcPrinterName
lnSuccess = ShellExecute(0, "PRINTTO", "C:\Test.Txt", lcPrintername, "", 1)
Post by DPM
Post by Villi Bernaroli
Post by DPM
Hi,
ShellExcute is used to print to a given printer as follows from VFP9.
DECLARE LONG ShellExecute IN "shell32.dll" LONG nHandle, STRING
cOperation, STRING cFile, ;
STRING vParameters, STRING cDirectory, LONG nShowCmd
lnSuccess = ShellExecute(0, "PRINTTO", "C:\Test.Txt", '"Printer
Name"', "", 1)
This works fine.
But the problem is when the name of the printer has a double
quote("), it does not print.
The following does not work.
eg. Assume the name of the printer is '"Printer "Name"' as the
parameter passed into ShellExecute()
=> Using 2 or 3 double quotes("") to represent a single double
quote("). eg. '"Printer ""Name"' or '"Printer """Name"'
=> Using slash and double quote(\") to represent a single double
quote("). eg. '"Printer \"Name"'
Could someone please advice what could be done to support printers
with a double quote in its name.
["Printer "Name"]
BTW it's strange that the printer's name contains an uneven number of
double quotes.
It would be more logical to use a even number, as in 'Printer "Name"'.
--
Villi Bernaroli, Italy
VFP, SOAP, MS SQLserver, MySQL, Oracle
Dan Freeman
2010-04-19 15:07:40 UTC
Permalink
Quotation marks are not valid in filenames. Why should we support them
in printer names, which are used in the very same way?

Tell the user that character is not allowed.

You may have a battle of wills with the net admin who, frankly, should
know better.

Dan
Post by DPM
Hi Jan,
Required user access is needed to rename a printer.
Specially network printers cannot be renamed unless user access is granted.
Also, renaming the printer may not be suitable in a multiuser enviroment.
Any other suggestions?
Post by Jan Bucek
Post by DPM
Hi, Villi,
Specifying the printer name as follows also does not work.
["Printer "Name"]
If the printer name has a odd number or even number of double quotes still
cannot print to it.
Any other alternatives?
1. rename the printer
2. try to use variable
store ["Printer Name"] to lcPrinterName
lnSuccess = ShellExecute(0, "PRINTTO", "C:\Test.Txt", lcPrintername, "", 1)
Post by DPM
Post by Villi Bernaroli
Post by DPM
Hi,
ShellExcute is used to print to a given printer as follows from VFP9.
DECLARE LONG ShellExecute IN "shell32.dll" LONG nHandle, STRING
cOperation, STRING cFile, ;
STRING vParameters, STRING cDirectory, LONG nShowCmd
lnSuccess = ShellExecute(0, "PRINTTO", "C:\Test.Txt", '"Printer
Name"', "", 1)
This works fine.
But the problem is when the name of the printer has a double
quote("), it does not print.
The following does not work.
eg. Assume the name of the printer is '"Printer "Name"' as the
parameter passed into ShellExecute()
=> Using 2 or 3 double quotes("") to represent a single double
quote("). eg. '"Printer ""Name"' or '"Printer """Name"'
=> Using slash and double quote(\") to represent a single double
quote("). eg. '"Printer \"Name"'
Could someone please advice what could be done to support printers
with a double quote in its name.
["Printer "Name"]
BTW it's strange that the printer's name contains an uneven number of
double quotes.
It would be more logical to use a even number, as in 'Printer "Name"'.
--
Villi Bernaroli, Italy
VFP, SOAP, MS SQLserver, MySQL, Oracle
Jan Bucek
2010-04-19 15:12:31 UTC
Permalink
Post by DPM
Hi Jan,
Required user access is needed to rename a printer.
Specially network printers cannot be renamed unless user access is granted.
Also, renaming the printer may not be suitable in a multiuser enviroment.
Any other suggestions?
1. try to use variable, as I have written

2. use another ways for printing TXT files, for example:
SET PRINTER TO NAME your_strange_printer_name
SET PRINTER ON
TYPE test.txt
SET PRINTER TO
SET PRINTER OFF
Post by DPM
Post by Jan Bucek
Post by DPM
Hi, Villi,
Specifying the printer name as follows also does not work.
["Printer "Name"]
If the printer name has a odd number or even number of double quotes still
cannot print to it.
Any other alternatives?
1. rename the printer
2. try to use variable
store ["Printer Name"] to lcPrinterName
lnSuccess = ShellExecute(0, "PRINTTO", "C:\Test.Txt", lcPrintername, "", 1)
Post by DPM
Post by Villi Bernaroli
Post by DPM
Hi,
ShellExcute is used to print to a given printer as follows from VFP9.
DECLARE LONG ShellExecute IN "shell32.dll" LONG nHandle, STRING
cOperation, STRING cFile, ;
STRING vParameters, STRING cDirectory, LONG nShowCmd
lnSuccess = ShellExecute(0, "PRINTTO", "C:\Test.Txt", '"Printer
Name"', "", 1)
This works fine.
But the problem is when the name of the printer has a double
quote("), it does not print.
The following does not work.
eg. Assume the name of the printer is '"Printer "Name"' as the
parameter passed into ShellExecute()
=> Using 2 or 3 double quotes("") to represent a single double
quote("). eg. '"Printer ""Name"' or '"Printer """Name"'
=> Using slash and double quote(\") to represent a single double
quote("). eg. '"Printer \"Name"'
Could someone please advice what could be done to support printers
with a double quote in its name.
["Printer "Name"]
BTW it's strange that the printer's name contains an uneven number of
double quotes.
It would be more logical to use a even number, as in 'Printer "Name"'.
--
Villi Bernaroli, Italy
VFP, SOAP, MS SQLserver, MySQL, Oracle
DPM
2010-04-20 04:04:37 UTC
Permalink
Hi Jan,

I guess this works only for text files.
But in this case it is required to print other file types too. eg. pdf, doc,
ect...
That's why ShellExecute was used to open the file with its associated
application from windows and print.
Post by Jan Bucek
Post by DPM
Hi Jan,
Required user access is needed to rename a printer.
Specially network printers cannot be renamed unless user access is granted.
Also, renaming the printer may not be suitable in a multiuser enviroment.
Any other suggestions?
1. try to use variable, as I have written
SET PRINTER TO NAME your_strange_printer_name
SET PRINTER ON
TYPE test.txt
SET PRINTER TO
SET PRINTER OFF
Post by DPM
Post by Jan Bucek
Post by DPM
Hi, Villi,
Specifying the printer name as follows also does not work.
["Printer "Name"]
If the printer name has a odd number or even number of double quotes still
cannot print to it.
Any other alternatives?
1. rename the printer
2. try to use variable
store ["Printer Name"] to lcPrinterName
lnSuccess = ShellExecute(0, "PRINTTO", "C:\Test.Txt", lcPrintername, "", 1)
Post by DPM
Post by Villi Bernaroli
Post by DPM
Hi,
ShellExcute is used to print to a given printer as follows from VFP9.
DECLARE LONG ShellExecute IN "shell32.dll" LONG nHandle, STRING
cOperation, STRING cFile, ;
STRING vParameters, STRING cDirectory, LONG nShowCmd
lnSuccess = ShellExecute(0, "PRINTTO", "C:\Test.Txt", '"Printer
Name"', "", 1)
This works fine.
But the problem is when the name of the printer has a double
quote("), it does not print.
The following does not work.
eg. Assume the name of the printer is '"Printer "Name"' as the
parameter passed into ShellExecute()
=> Using 2 or 3 double quotes("") to represent a single double
quote("). eg. '"Printer ""Name"' or '"Printer """Name"'
=> Using slash and double quote(\") to represent a single double
quote("). eg. '"Printer \"Name"'
Could someone please advice what could be done to support printers
with a double quote in its name.
["Printer "Name"]
BTW it's strange that the printer's name contains an uneven number of
double quotes.
It would be more logical to use a even number, as in 'Printer "Name"'.
--
Villi Bernaroli, Italy
VFP, SOAP, MS SQLserver, MySQL, Oracle
JayB
2010-04-20 04:08:40 UTC
Permalink
leave off the printer name altogether
and the user will be prompted using the std windows printer selection,
or perhaps it will print to the users default printer.
Post by DPM
Hi Jan,
Required user access is needed to rename a printer.
Specially network printers cannot be renamed unless user access is granted.
Also, renaming the printer may not be suitable in a multiuser enviroment.
Any other suggestions?
Post by Jan Bucek
Post by DPM
Hi, Villi,
Specifying the printer name as follows also does not work.
["Printer "Name"]
If the printer name has a odd number or even number of double quotes still
cannot print to it.
Any other alternatives?
1. rename the printer
2. try to use variable
store ["Printer Name"] to lcPrinterName
lnSuccess = ShellExecute(0, "PRINTTO", "C:\Test.Txt", lcPrintername, "", 1)
Post by DPM
Post by Villi Bernaroli
Post by DPM
Hi,
ShellExcute is used to print to a given printer as follows from VFP9.
DECLARE LONG ShellExecute IN "shell32.dll" LONG nHandle, STRING
cOperation, STRING cFile, ;
STRING vParameters, STRING cDirectory, LONG nShowCmd
lnSuccess = ShellExecute(0, "PRINTTO", "C:\Test.Txt", '"Printer
Name"', "", 1)
This works fine.
But the problem is when the name of the printer has a double
quote("), it does not print.
The following does not work.
eg. Assume the name of the printer is '"Printer "Name"' as the
parameter passed into ShellExecute()
=> Using 2 or 3 double quotes("") to represent a single double
quote("). eg. '"Printer ""Name"' or '"Printer """Name"'
=> Using slash and double quote(\") to represent a single double
quote("). eg. '"Printer \"Name"'
Could someone please advice what could be done to support printers
with a double quote in its name.
["Printer "Name"]
BTW it's strange that the printer's name contains an uneven number of
double quotes.
It would be more logical to use a even number, as in 'Printer "Name"'.
--
Villi Bernaroli, Italy
VFP, SOAP, MS SQLserver, MySQL, Oracle
DPM
2010-04-26 04:06:43 UTC
Permalink
Hi all,

Thanks for all your replies and comments.
As there is no way to overcome this, as suggested it is best to validate if
the printer name has a double quote in it and warn the user.
Post by DPM
Hi Jan,
Required user access is needed to rename a printer.
Specially network printers cannot be renamed unless user access is granted.
Also, renaming the printer may not be suitable in a multiuser enviroment.
Any other suggestions?
Post by Jan Bucek
Post by DPM
Hi, Villi,
Specifying the printer name as follows also does not work.
["Printer "Name"]
If the printer name has a odd number or even number of double quotes still
cannot print to it.
Any other alternatives?
1. rename the printer
2. try to use variable
store ["Printer Name"] to lcPrinterName
lnSuccess = ShellExecute(0, "PRINTTO", "C:\Test.Txt", lcPrintername, "", 1)
Post by DPM
Post by Villi Bernaroli
Post by DPM
Hi,
ShellExcute is used to print to a given printer as follows from VFP9.
DECLARE LONG ShellExecute IN "shell32.dll" LONG nHandle, STRING
cOperation, STRING cFile, ;
STRING vParameters, STRING cDirectory, LONG nShowCmd
lnSuccess = ShellExecute(0, "PRINTTO", "C:\Test.Txt", '"Printer
Name"', "", 1)
This works fine.
But the problem is when the name of the printer has a double
quote("), it does not print.
The following does not work.
eg. Assume the name of the printer is '"Printer "Name"' as the
parameter passed into ShellExecute()
=> Using 2 or 3 double quotes("") to represent a single double
quote("). eg. '"Printer ""Name"' or '"Printer """Name"'
=> Using slash and double quote(\") to represent a single double
quote("). eg. '"Printer \"Name"'
Could someone please advice what could be done to support printers
with a double quote in its name.
["Printer "Name"]
BTW it's strange that the printer's name contains an uneven number of
double quotes.
It would be more logical to use a even number, as in 'Printer "Name"'.
--
Villi Bernaroli, Italy
VFP, SOAP, MS SQLserver, MySQL, Oracle
ED
2010-04-20 06:54:07 UTC
Permalink
Build the string using the CHR() value of the double quotes. (I'll leave it
to you to look it up ;-) ).
ED


"DPM" <***@bb.cc> wrote in message news:%***@TK2MSFTNGP04.phx.gbl...
Hi,

ShellExcute is used to print to a given printer as follows from VFP9.

DECLARE LONG ShellExecute IN "shell32.dll" LONG nHandle, STRING cOperation,
STRING cFile, ;
STRING vParameters, STRING cDirectory, LONG nShowCmd

lnSuccess = ShellExecute(0, "PRINTTO", "C:\Test.Txt", '"Printer Name"', "",
1)

This works fine.
But the problem is when the name of the printer has a double quote("), it
does not print.

The following does not work.
eg. Assume the name of the printer is '"Printer "Name"' as the parameter
passed into ShellExecute()
=> Using 2 or 3 double quotes("") to represent a single double quote("). eg.
'"Printer ""Name"' or '"Printer """Name"'
=> Using slash and double quote(\") to represent a single double quote(").
eg. '"Printer \"Name"'

Could someone please advice what could be done to support printers with a
double quote in its name.
Gregory Adam
2010-04-20 09:04:58 UTC
Permalink
And in what way is this different from Villi's suggestion ?
--
Gregory
_
Post by ED
Build the string using the CHR() value of the double quotes. (I'll leave it
to you to look it up ;-) ).
ED
Hi,
ShellExcute is used to print to a given printer as follows from VFP9.
DECLARE LONG ShellExecute IN "shell32.dll" LONG nHandle, STRING cOperation,
STRING cFile, ;
STRING vParameters, STRING cDirectory, LONG nShowCmd
lnSuccess = ShellExecute(0, "PRINTTO", "C:\Test.Txt", '"Printer Name"', "",
1)
This works fine.
But the problem is when the name of the printer has a double quote("), it
does not print.
The following does not work.
eg. Assume the name of the printer is '"Printer "Name"' as the parameter
passed into ShellExecute()
=> Using 2 or 3 double quotes("") to represent a single double quote("). eg.
'"Printer ""Name"' or '"Printer """Name"'
=> Using slash and double quote(\") to represent a single double quote(").
eg. '"Printer \"Name"'
Could someone please advice what could be done to support printers with a
double quote in its name.
ED
2010-04-21 07:42:02 UTC
Permalink
Where exactly did he suggest this?


"Gregory Adam" <***@hotmail.com> wrote in message news:BDFF7EED-040E-4FCF-88E6-***@microsoft.com...
And in what way is this different from Villi's suggestion ?
--
Gregory
_
Post by ED
Build the string using the CHR() value of the double quotes. (I'll leave it
to you to look it up ;-) ).
ED
Hi,
ShellExcute is used to print to a given printer as follows from VFP9.
DECLARE LONG ShellExecute IN "shell32.dll" LONG nHandle, STRING cOperation,
STRING cFile, ;
STRING vParameters, STRING cDirectory, LONG nShowCmd
lnSuccess = ShellExecute(0, "PRINTTO", "C:\Test.Txt", '"Printer Name"', "",
1)
This works fine.
But the problem is when the name of the printer has a double quote("), it
does not print.
The following does not work.
eg. Assume the name of the printer is '"Printer "Name"' as the parameter
passed into ShellExecute()
=> Using 2 or 3 double quotes("") to represent a single double quote("). eg.
'"Printer ""Name"' or '"Printer """Name"'
=> Using slash and double quote(\") to represent a single double quote(").
eg. '"Printer \"Name"'
Could someone please advice what could be done to support printers with a
double quote in its name.
Loading...