Solved

Data output problem

Posted on 2000-03-27
3
145 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

820 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