Solved

Data output problem

Posted on 2000-03-27
3
147 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

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…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses
Course of the Month4 days, 17 hours left to enroll

635 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