Solved

Data output problem

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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
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.
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…
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…

708 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now