Solved

Data output problem

Posted on 2000-03-27
3
144 Views
Last Modified: 2010-05-02
I have two questions for you.  The person who gets both of them will get the points.


First question :-

My program needs to be able to output to the printer and the screen.  Rather then writing two sets of code can I put a pointer to a device and output to that?

Eg.

Rather than:

If output type = screen
  FrmOutputtoScreen.print Data
Elseif output type = printer
  Printer.print Data
Endif

Can I:

If output = screen then device = screen
If output = printer then device = printer

Device.print Data

Second question :-

I am outputing data to an MSFlexGrid control.  I need to be able to copy this data to the clipboard and paste into Excel.

How do I do this (code or otherwise)

Regards,
Daniel Arnison

0
Comment
Question by:darnison062499
3 Comments
 
LVL 14

Accepted Solution

by:
mcrider earned 200 total points
ID: 2661948
For question #1...

If you set up a global variable in a MODULE like this:
 
   Global OutDevice As Object

Then you can set this object to either the printer or the form... For example, if you have a routine like this:


   Sub MySub()
      OutDevice.Print "Hello There"
      OutDevice.Print "How Are You?"
   End Sub

Before you call the above subroutine, Do this to have the subroutine print to the printer:

   Set OutDevice = Printer

and do this if you want to have the subroutine print to a form:

   Set OutDevice = Form1




For Question #2...

Put the cells you want from the flexgrid in a string, separating columns with VbTabs and rows with VbCrLf... For example:

   Dim lBuf As String

   For lrow = 1 To 4
       For lcol = 1 To 4
           lBuf = lBuf + MSFlexGrid1.TextMatrix(lrow, lcol) + vbTab
       Next lcol
       lBuf = Right$(lBuf, Len(lBuf) - 1) + vbCrLf
   Next lrow
   Clipboard.Clear
   Clipboard.SetText lBuf



Cheers!®©

By the way, EE folks really like it if you ask only 1 question per post....



0
 
LVL 10

Expert Comment

by:caraf_g
ID: 2664156
<doing my "trading places" thing again>

Yeah.
0
 

Author Comment

by:darnison062499
ID: 2665400
The points are yours
0

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question