|
 |
asp_web_howto thread: Printing Labels
Message #1 by "Rob Taylor - tconsult.com" <rob@t...> on Thu, 12 Dec 2002 12:07:56 -0500
|
|
Hello
I have a client who wants to print labels directly from their web site however I don't know if it can be done.
My experience with labels would tell me you need word processing software to do it. What I was thinking
is I could export the grid to MS Excel on the fly and print them from there IF you can print labels from Excel.
What about exporting the grid MS Word?
Has anyone stumbled on to some sort of COM or know of another way to do this?
Thanks,
Rob Taylor
www.tconsult.com
rob@t...
xxx-xxx-xxxx
Customized Internet Solutions for Outdoor People
Message #2 by Jack_Speranza <jsperanza@g...> on Thu, 12 Dec 2002 13:34:47 -0500
|
|
You hit the nail on the head... you would want to access a program on the
client to handle the printing for you. We have developed an intranet
application (we know we have IE on all our clients) which invokes Word from
the web page to print off mailing labels. Fortunately, because we are in
control of both the server and the client machines, we can deal with all
security and role issues pretty easily... this would be very difficult to
implement on a more generic basis.
Not sure if this helps or not...
******************************
Jack Speranza
Gryphon Networks
Automating Privacy Compliance for Business
xxx.xxx.xxxx x129
www.gryphonnetworks.com
"Software never has bugs. It just develops random features."
-----Original Message-----
From: Rob Taylor - tconsult.com [mailto:rob@t...]
Sent: Thursday, December 12, 2002 12:08 PM
To: ASP Web HowTo
Subject: [asp_web_howto] Printing Labels
Hello
I have a client who wants to print labels directly from their web site
however I don't know if it can be done.
My experience with labels would tell me you need word processing software to
do it. What I was thinking
is I could export the grid to MS Excel on the fly and print them from there
IF you can print labels from Excel.
What about exporting the grid MS Word?
Has anyone stumbled on to some sort of COM or know of another way to do
this?
Thanks,
Rob Taylor
www.tconsult.com
rob@t...
xxx-xxx-xxxx
Customized Internet Solutions for Outdoor People
Message #3 by "Rob Taylor - tconsult.com" <rob@t...> on Thu, 12 Dec 2002 13:39:51 -0500
|
|
Yes it does help just so I know my thinking is straight. I could easily
export something to MS
Word. However how would you export it to word and also have it open in the
Label template?
Is this how you did it? Or do you have to copy and paste something once you
get a .doc file?
Thanks,
Rob
----- Original Message -----
From: "Jack_Speranza" <jsperanza@g...>
To: "ASP Web HowTo" <asp_web_howto@p...>
Sent: Thursday, December 12, 2002 1:34 PM
Subject: [asp_web_howto] RE: Printing Labels
>
> You hit the nail on the head... you would want to access a program on the
> client to handle the printing for you. We have developed an intranet
> application (we know we have IE on all our clients) which invokes Word
from
> the web page to print off mailing labels. Fortunately, because we are in
> control of both the server and the client machines, we can deal with all
> security and role issues pretty easily... this would be very difficult to
> implement on a more generic basis.
>
> Not sure if this helps or not...
>
>
> ******************************
> Jack Speranza
> Gryphon Networks
> Automating Privacy Compliance for Business
> xxx.xxx.xxxx x129
> www.gryphonnetworks.com
>
> "Software never has bugs. It just develops random features."
>
>
>
> -----Original Message-----
> From: Rob Taylor - tconsult.com [mailto:rob@t...]
> Sent: Thursday, December 12, 2002 12:08 PM
> To: ASP Web HowTo
> Subject: [asp_web_howto] Printing Labels
>
>
> Hello
>
> I have a client who wants to print labels directly from their web site
> however I don't know if it can be done.
> My experience with labels would tell me you need word processing software
to
> do it. What I was thinking
> is I could export the grid to MS Excel on the fly and print them from
there
> IF you can print labels from Excel.
> What about exporting the grid MS Word?
>
> Has anyone stumbled on to some sort of COM or know of another way to do
> this?
>
> Thanks,
>
>
> Rob Taylor
> www.tconsult.com
> rob@t...
> xxx-xxx-xxxx
> Customized Internet Solutions for Outdoor People
>
>
>
>
>
Message #4 by Jack_Speranza <jsperanza@g...> on Thu, 12 Dec 2002 14:35:49 -0500
|
|
Rob --
Here's snippets of the code from one of our intranet web pages that we
utilize to print labels. It is client side vbscript, so it would work
in IE only. Hope you can follow the gist of everything so as to
modify to your own needs (FYI - there's some coordination going on with
a server side record set that was saved to the client in the form
of a delimited string)...
Jack
<CODE>
Sub UpdatePrint(bPrint)
Dim oApp, oDoc, oMergedDoc, oWin
Dim sFileName, dbToday
Dim i, cols, arrKeys
Dim sKeys, strHead, strSelectedData
' SET DEFAULT VALUES
cols=<%=cols%> ' Number of columns returned by server-side
recordset
dbToday = Date()
sFileName = "Labels_" & Year(dbToday) & "_" & Month(dbToday) & "_" &
Day(dbToday) & ".doc"
' CONFIRM SELECTIONS WITH USER
if bPrint then
Call MsgBox("Please wait while we create your mailing
labels. They will be saved " & _
"on your C drive as " &
sFileName & ".")
else
If MsgBox ("Are you certain you do NOT wish to proceed with
creating mailing " & _
"labels for this
list?",vbYesNo) = vbYes then
' PROCESS FORM
document.frm.submit()
exit sub
else
Call MsgBox("Please wait while we create your
mailing labels. They will be saved " & _
"on your C drive as " &
sFileName & ".")
end if
end if
' CREATE ARRAY OF KEY VALUES SELECTED FOR LABEL PRINTING
sKeys = getSelectedRowKeys()
if isNull(sKeys) or Len(sKeys) < 1 then
Call MsgBox("You did not select any records for which to
print labels.")
exit sub
end if
arrKeys = split(sKeys,",")
' NOW PARSE DATA ROWS FOR WHICH WE WANT TO PRINT LABELS
For i = 0 to UBound(arrKeys)
strSelectedData = strSelectedData & GetRow(sRSData,
arrKeys(i), "|", "", cols)
Next
' ADD HEADER ROW TO DATASET
strHead = GetRow(sRSData, "header", "|", "", cols)
strSelectedData = strHead & strSelectedData
if len(strSelectedData) < (len(strHead) + 10) then
Call MsgBox("Unexpected error encountered. Please report to
Engineering.")
Exit Sub
end if
On error resume next
' OPEN INSTANCE OF WORD
Set oApp = CreateObject("Word.Application")
' LET'S CREATE A SIMPLE STATUS SCREEN
set oWin
window.open("statusScreen.htm","status","toolbar=0,location=0,status=0,direc
tories=0,scrollbars=0,menubar=0,resizable=0,width=350,height=320,top=175,lef
t=250")
oWin.focus()
' CREATE DATA PAGE
CreateDataDoc oApp,strSelectedData,"|", cols
Set oDoc = oApp.Documents.Add
With oDoc.MailMerge
.Fields.Add oApp.Selection.Range, "CompanyName"
oApp.Selection.TypeParagraph
.Fields.Add oApp.Selection.Range, "ContactName"
oApp.Selection.TypeParagraph
.Fields.Add oApp.Selection.Range, "Address1"
oApp.Selection.TypeParagraph
.Fields.Add oApp.Selection.Range, "Address2"
oApp.Selection.TypeParagraph
.Fields.Add oApp.Selection.Range, "City"
oApp.Selection.TypeText ", "
.Fields.Add oApp.Selection.Range, "State"
oApp.Selection.TypeText " "
.Fields.Add oApp.Selection.Range, "Postal"
oApp.Selection.TypeParagraph
.Fields.Add oApp.Selection.Range, "ListName"
oApp.Selection.TypeParagraph
Dim oAutoText
Set oAutoText
oApp.NormalTemplate.AutoTextEntries.Add("LabelLayout", oDoc.Content)
oDoc.Content.Delete
.MainDocumentType = 1 ' 1 = wdMailingLabels
.OpenDataSource "C:\data.doc"
oApp.MailingLabel.CreateNewDocument "5160", "",
"LabelLayout", , 4 ' 4 = wdPrinterManualFeed
.Destination = 0 ' 0 = wdSendToNewDocument
.Execute
oAutoText.Delete
End With
oDoc.Close False
Set oMergedDoc = oApp.ActiveDocument
' FORMAT LABELS
oApp.Selection.WholeStory
oApp.Selection.Font.Name = "Courier New"
oApp.Selection.Font.Size = 10
' SAVE AND CLOSE
oMergedDoc.SaveAs "C:\" & sFileName
oMergedDoc.Close False
oApp.Quit False
oWin.close()
' SUBMIT FORM AND CONFIRM ALL IS WELL
document.frm.submit()
Call MsgBox("Delivery Information updated and labels saved at C:\" &
sFileName)
End Sub
Sub CreateDataDoc(oApp, strData, strDelim, cols)
dim oDoc, oRange
Set oDoc = oApp.Documents.Add
Set oRange = oDoc.Range
oRange.Text = strData
oRange.ConvertToTable strDelim,,cols
oDoc.SaveAs "C:\data.doc"
oDoc.Close false
End Sub
-----Original Message-----
From: Rob Taylor - tconsult.com [mailto:rob@t...]
Sent: Thursday, December 12, 2002 1:40 PM
To: ASP Web HowTo
Subject: [asp_web_howto] RE: Printing Labels
Yes it does help just so I know my thinking is straight. I could easily
export something to MS
Word. However how would you export it to word and also have it open in the
Label template?
Is this how you did it? Or do you have to copy and paste something once you
get a .doc file?
Thanks,
Rob
Message #5 by "Rob Taylor - tconsult.com" <rob@t...> on Thu, 12 Dec 2002 14:54:46 -0500
|
|
Awesome! Thank you. That helps a ton. I will see if I can get it to
work.
That does not look that difficult plus I will not need those pop up windows.
Thanks again.
Rob Taylor
www.tconsult.com
rob@t...
xxx-xxx-xxxx
Customized Internet Solutions for Outdoor People
----- Original Message -----
From: "Jack_Speranza" <jsperanza@g...>
To: "ASP Web HowTo" <asp_web_howto@p...>
Sent: Thursday, December 12, 2002 2:35 PM
Subject: [asp_web_howto] RE: Printing Labels
>
> Rob --
>
> Here's snippets of the code from one of our intranet web pages that we
> utilize to print labels. It is client side vbscript, so it would work
> in IE only. Hope you can follow the gist of everything so as to
> modify to your own needs (FYI - there's some coordination going on with
> a server side record set that was saved to the client in the form
> of a delimited string)...
>
> Jack
>
> <CODE>
>
> Sub UpdatePrint(bPrint)
> Dim oApp, oDoc, oMergedDoc, oWin
> Dim sFileName, dbToday
> Dim i, cols, arrKeys
> Dim sKeys, strHead, strSelectedData
>
> ' SET DEFAULT VALUES
> cols=<%=cols%> ' Number of columns returned by server-side
> recordset
> dbToday = Date()
> sFileName = "Labels_" & Year(dbToday) & "_" & Month(dbToday) & "_" &
> Day(dbToday) & ".doc"
>
>
> ' CONFIRM SELECTIONS WITH USER
> if bPrint then
> Call MsgBox("Please wait while we create your mailing
> labels. They will be saved " & _
> "on your C drive as " &
> sFileName & ".")
> else
> If MsgBox ("Are you certain you do NOT wish to proceed with
> creating mailing " & _
> "labels for this
> list?",vbYesNo) = vbYes then
> ' PROCESS FORM
> document.frm.submit()
> exit sub
> else
> Call MsgBox("Please wait while we create your
> mailing labels. They will be saved " & _
> "on your C drive as " &
> sFileName & ".")
> end if
> end if
>
>
> ' CREATE ARRAY OF KEY VALUES SELECTED FOR LABEL PRINTING
> sKeys = getSelectedRowKeys()
>
> if isNull(sKeys) or Len(sKeys) < 1 then
> Call MsgBox("You did not select any records for which to
> print labels.")
> exit sub
> end if
>
> arrKeys = split(sKeys,",")
>
> ' NOW PARSE DATA ROWS FOR WHICH WE WANT TO PRINT LABELS
> For i = 0 to UBound(arrKeys)
> strSelectedData = strSelectedData & GetRow(sRSData,
> arrKeys(i), "|", "", cols)
> Next
>
> ' ADD HEADER ROW TO DATASET
> strHead = GetRow(sRSData, "header", "|", "", cols)
> strSelectedData = strHead & strSelectedData
>
> if len(strSelectedData) < (len(strHead) + 10) then
> Call MsgBox("Unexpected error encountered. Please report to
> Engineering.")
> Exit Sub
> end if
>
> On error resume next
>
> ' OPEN INSTANCE OF WORD
> Set oApp = CreateObject("Word.Application")
>
> ' LET'S CREATE A SIMPLE STATUS SCREEN
> set oWin
>
window.open("statusScreen.htm","status","toolbar=0,location=0,status=0,direc
>
tories=0,scrollbars=0,menubar=0,resizable=0,width=350,height=320,top=175,lef
> t=250")
> oWin.focus()
>
> ' CREATE DATA PAGE
> CreateDataDoc oApp,strSelectedData,"|", cols
>
> Set oDoc = oApp.Documents.Add
> With oDoc.MailMerge
> .Fields.Add oApp.Selection.Range, "CompanyName"
> oApp.Selection.TypeParagraph
> .Fields.Add oApp.Selection.Range, "ContactName"
> oApp.Selection.TypeParagraph
> .Fields.Add oApp.Selection.Range, "Address1"
> oApp.Selection.TypeParagraph
> .Fields.Add oApp.Selection.Range, "Address2"
> oApp.Selection.TypeParagraph
> .Fields.Add oApp.Selection.Range, "City"
> oApp.Selection.TypeText ", "
> .Fields.Add oApp.Selection.Range, "State"
> oApp.Selection.TypeText " "
> .Fields.Add oApp.Selection.Range, "Postal"
> oApp.Selection.TypeParagraph
> .Fields.Add oApp.Selection.Range, "ListName"
> oApp.Selection.TypeParagraph
>
> Dim oAutoText
> Set oAutoText
> oApp.NormalTemplate.AutoTextEntries.Add("LabelLayout", oDoc.Content)
> oDoc.Content.Delete
> .MainDocumentType = 1 ' 1 = wdMailingLabels
>
> .OpenDataSource "C:\data.doc"
>
> oApp.MailingLabel.CreateNewDocument "5160", "",
> "LabelLayout", , 4 ' 4 = wdPrinterManualFeed
>
> .Destination = 0 ' 0 = wdSendToNewDocument
> .Execute
>
> oAutoText.Delete
> End With
>
> oDoc.Close False
>
> Set oMergedDoc = oApp.ActiveDocument
>
> ' FORMAT LABELS
> oApp.Selection.WholeStory
>
> oApp.Selection.Font.Name = "Courier New"
> oApp.Selection.Font.Size = 10
>
> ' SAVE AND CLOSE
> oMergedDoc.SaveAs "C:\" & sFileName
> oMergedDoc.Close False
> oApp.Quit False
>
> oWin.close()
>
> ' SUBMIT FORM AND CONFIRM ALL IS WELL
> document.frm.submit()
> Call MsgBox("Delivery Information updated and labels saved at C:\" &
> sFileName)
> End Sub
>
>
> Sub CreateDataDoc(oApp, strData, strDelim, cols)
> dim oDoc, oRange
>
> Set oDoc = oApp.Documents.Add
>
> Set oRange = oDoc.Range
> oRange.Text = strData
> oRange.ConvertToTable strDelim,,cols
>
> oDoc.SaveAs "C:\data.doc"
> oDoc.Close false
> End Sub
>
>
> -----Original Message-----
> From: Rob Taylor - tconsult.com [mailto:rob@t...]
> Sent: Thursday, December 12, 2002 1:40 PM
> To: ASP Web HowTo
> Subject: [asp_web_howto] RE: Printing Labels
>
>
> Yes it does help just so I know my thinking is straight. I could easily
> export something to MS
> Word. However how would you export it to word and also have it open in
the
> Label template?
> Is this how you did it? Or do you have to copy and paste something once
you
> get a .doc file?
>
> Thanks,
>
>
> Rob
>
>
>
>
Message #6 by "Rob Taylor - tconsult.com" <rob@t...> on Fri, 13 Dec 2002 16:49:48 -0500
|
|
Wouldn't I be able to just save the label generated file as .doc field
and then have the client download and open it? I don't need MS
Word on the server I believe.
Thanks,
Rob
----- Original Message -----
From: "Jack_Speranza" <jsperanza@g...>
To: "ASP Web HowTo" <asp_web_howto@p...>
Sent: Thursday, December 12, 2002 2:35 PM
Subject: [asp_web_howto] RE: Printing Labels
>
> Rob --
>
> Here's snippets of the code from one of our intranet web pages that we
> utilize to print labels. It is client side vbscript, so it would work
> in IE only. Hope you can follow the gist of everything so as to
> modify to your own needs (FYI - there's some coordination going on with
> a server side record set that was saved to the client in the form
> of a delimited string)...
>
> Jack
>
> <CODE>
>
> Sub UpdatePrint(bPrint)
> Dim oApp, oDoc, oMergedDoc, oWin
> Dim sFileName, dbToday
> Dim i, cols, arrKeys
> Dim sKeys, strHead, strSelectedData
>
> ' SET DEFAULT VALUES
> cols=<%=cols%> ' Number of columns returned by server-side
> recordset
> dbToday = Date()
> sFileName = "Labels_" & Year(dbToday) & "_" & Month(dbToday) & "_" &
> Day(dbToday) & ".doc"
>
>
> ' CONFIRM SELECTIONS WITH USER
> if bPrint then
> Call MsgBox("Please wait while we create your mailing
> labels. They will be saved " & _
> "on your C drive as " &
> sFileName & ".")
> else
> If MsgBox ("Are you certain you do NOT wish to proceed with
> creating mailing " & _
> "labels for this
> list?",vbYesNo) = vbYes then
> ' PROCESS FORM
> document.frm.submit()
> exit sub
> else
> Call MsgBox("Please wait while we create your
> mailing labels. They will be saved " & _
> "on your C drive as " &
> sFileName & ".")
> end if
> end if
>
>
> ' CREATE ARRAY OF KEY VALUES SELECTED FOR LABEL PRINTING
> sKeys = getSelectedRowKeys()
>
> if isNull(sKeys) or Len(sKeys) < 1 then
> Call MsgBox("You did not select any records for which to
> print labels.")
> exit sub
> end if
>
> arrKeys = split(sKeys,",")
>
> ' NOW PARSE DATA ROWS FOR WHICH WE WANT TO PRINT LABELS
> For i = 0 to UBound(arrKeys)
> strSelectedData = strSelectedData & GetRow(sRSData,
> arrKeys(i), "|", "", cols)
> Next
>
> ' ADD HEADER ROW TO DATASET
> strHead = GetRow(sRSData, "header", "|", "", cols)
> strSelectedData = strHead & strSelectedData
>
> if len(strSelectedData) < (len(strHead) + 10) then
> Call MsgBox("Unexpected error encountered. Please report to
> Engineering.")
> Exit Sub
> end if
>
> On error resume next
>
> ' OPEN INSTANCE OF WORD
> Set oApp = CreateObject("Word.Application")
>
> ' LET'S CREATE A SIMPLE STATUS SCREEN
> set oWin
>
window.open("statusScreen.htm","status","toolbar=0,location=0,status=0,direc
>
tories=0,scrollbars=0,menubar=0,resizable=0,width=350,height=320,top=175,lef
> t=250")
> oWin.focus()
>
> ' CREATE DATA PAGE
> CreateDataDoc oApp,strSelectedData,"|", cols
>
> Set oDoc = oApp.Documents.Add
> With oDoc.MailMerge
> .Fields.Add oApp.Selection.Range, "CompanyName"
> oApp.Selection.TypeParagraph
> .Fields.Add oApp.Selection.Range, "ContactName"
> oApp.Selection.TypeParagraph
> .Fields.Add oApp.Selection.Range, "Address1"
> oApp.Selection.TypeParagraph
> .Fields.Add oApp.Selection.Range, "Address2"
> oApp.Selection.TypeParagraph
> .Fields.Add oApp.Selection.Range, "City"
> oApp.Selection.TypeText ", "
> .Fields.Add oApp.Selection.Range, "State"
> oApp.Selection.TypeText " "
> .Fields.Add oApp.Selection.Range, "Postal"
> oApp.Selection.TypeParagraph
> .Fields.Add oApp.Selection.Range, "ListName"
> oApp.Selection.TypeParagraph
>
> Dim oAutoText
> Set oAutoText
> oApp.NormalTemplate.AutoTextEntries.Add("LabelLayout", oDoc.Content)
> oDoc.Content.Delete
> .MainDocumentType = 1 ' 1 = wdMailingLabels
>
> .OpenDataSource "C:\data.doc"
>
> oApp.MailingLabel.CreateNewDocument "5160", "",
> "LabelLayout", , 4 ' 4 = wdPrinterManualFeed
>
> .Destination = 0 ' 0 = wdSendToNewDocument
> .Execute
>
> oAutoText.Delete
> End With
>
> oDoc.Close False
>
> Set oMergedDoc = oApp.ActiveDocument
>
> ' FORMAT LABELS
> oApp.Selection.WholeStory
>
> oApp.Selection.Font.Name = "Courier New"
> oApp.Selection.Font.Size = 10
>
> ' SAVE AND CLOSE
> oMergedDoc.SaveAs "C:\" & sFileName
> oMergedDoc.Close False
> oApp.Quit False
>
> oWin.close()
>
> ' SUBMIT FORM AND CONFIRM ALL IS WELL
> document.frm.submit()
> Call MsgBox("Delivery Information updated and labels saved at C:\" &
> sFileName)
> End Sub
>
>
> Sub CreateDataDoc(oApp, strData, strDelim, cols)
> dim oDoc, oRange
>
> Set oDoc = oApp.Documents.Add
>
> Set oRange = oDoc.Range
> oRange.Text = strData
> oRange.ConvertToTable strDelim,,cols
>
> oDoc.SaveAs "C:\data.doc"
> oDoc.Close false
> End Sub
>
>
> -----Original Message-----
> From: Rob Taylor - tconsult.com [mailto:rob@t...]
> Sent: Thursday, December 12, 2002 1:40 PM
> To: ASP Web HowTo
> Subject: [asp_web_howto] RE: Printing Labels
>
>
> Yes it does help just so I know my thinking is straight. I could easily
> export something to MS
> Word. However how would you export it to word and also have it open in
the
> Label template?
> Is this how you did it? Or do you have to copy and paste something once
you
> get a .doc file?
>
> Thanks,
>
>
> Rob
>
>
>
>
Message #7 by "Rob Taylor - tconsult.com" <rob@t...> on Wed, 18 Dec 2002 13:15:00 -0500
|
|
Hello All
My question relates to this previous thread if anyone is interested. That
is what this is
based off of. Thanks Cindy :)
http://p2p.wrox.com/archive/asp_web_howto/2002-09/9.asp
I am creating text files that then need to be downloaded. I need the dialog
box to open. Everything is fine
except when I am getting the error below. I know the path is right and it
would seem the file is being found.
To my uderstanding the contenttype is irrelevant. It just needs to specify
something. If this is wrong
then what is the proper contant type for text files. Why can this file not
be opened? Thanks......Rob
ADODB.Stream error '800a0bba'
File could not be opened.
/listcustomer.asp, line 51
'Creates the text file and names it 44.txt
'Adds the text - This is my text file
set fs = CreateObject("Scripting.FileSystemObject")
Filepath = Server.MapPath("Labels")
Filepath = FilePath & "\" & "44.txt"
Filepath = trim(Filepath)
set a = fs.CreateTextFile(FilePath,True)
a.writeline("This is my text file")
'set headers to invoke dialog box for downloading
response.clear
Response.contenttype="application/zip"
Response.AddHeader "content-disposition", "attachment;filename=44.txt"
Response.BinaryWrite getBinaryFile(FilePath)
'function for grabbing file
function getBinaryFile(fileSpec)
Dim adTypeBinary
adTypeBinary = 1
Dim oStream
set oStream = server.createobject("ADODB.Stream")
oStream.Open
oStream.Type = adTypeBinary
oStream.LoadFromFile fileSpec '*** Line 51
getBinaryFile= oStream.read
set oStream=nothing
End Function
|
|
 |