View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Ron Rosenfeld[_2_] Ron Rosenfeld[_2_] is offline
external usenet poster
 
Posts: 1,045
Default Auto Detect Data, Auto Print Data, Auto Erase Data Loop

On Mon, 12 Sep 2011 19:18:02 -0700 (PDT), GammaRuit wrote:

Works Ron ! Thank You

Do I need to Define A Header and Footer within the Macro?
I tried to apply it in the layout and it won't work.

What would be a better description of the interface be? The type of
Scanner?
Would you like to see a video of how it works so you can understand
the process?

Chris


Glad you've got it working.

So far as the Header and Footer are concerned, I don't understand why you cannot set it up in the "layout". I can go to the Page Layout tab of my ribbon; select Print Titles; enter header and footer; and it "sticks".

If you want to set it up in the macro, you certainly can, but it shouldn't be necessary:
=========================
Option Explicit

Private Sub Worksheet_Change(ByVal Target As Range)
Dim rBarCodeData As Range
Dim AOI As Range
Const sLastLine As String = "END"
Set AOI = Range("A:A")

Application.EnableEvents = False

If Not Intersect(Target, AOI) Is Nothing And _
Target.Value = sLastLine Then
Set rBarCodeData = Range("A1", Cells(Cells.Rows.Count, "A").End(xlUp))
With rBarCodeData
With .Worksheet.PageSetup
.CenterHeader = "": .RightHeader = ""
.CenterFooter = "": .RightFooter = ""
.LeftHeader = "This is my Barcode output"
.LeftFooter = "Printed at " & Format(Date, "Short Date") & _
" " & Format(Time, "h:mm AM/PM")
End With
.PrintOut Preview:=True
.ClearContents
End With

With Range("A1")
.Activate
.Show
End With

End If
Application.EnableEvents = True
End Sub
=============================

So far as the interface is concerned, all you've written is that you scan something in and it appears in your Excel instance in certain cells.

That is not sufficient information for anyone to reproduce what you are doing. For example, if I have a computer here, turn it on and run Excel, and then run a scanner, nothing will appear in my Excel.

There has to be something going on that routes the information from the scanner to a particular instance of Excel, and directs it towards the sequential cells. This usually involves a VBA macro, or some other code.

However, since you seem to have the macro working satisfactorily, there is no need to go further. (Perfect is the enemy of "good enough"). But if you can't define a header or footer, even within the macro, there is possibly something in those routines that is interfering. In that case we would have to know all the details.