Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Data output problem

Posted on 2000-03-27
3
Medium Priority
?
149 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 600 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
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…
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…

926 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