You are not registered yet. Please click here to register!


 
 
plc storereviewsdownloads
This board is for PLC Related Q&A ONLY. Please DON'T use it for advertising, etc.
 
Try our online PLC Simulator- FREE.  Click here now to try it.

---------->>>>>Get FREE PLC Programming Tips

New Here? Please read this important info!!!


Go Back   PLCS.net - Interactive Q & A > PLCS.net - Interactive Q & A > LIVE PLC Questions And Answers

PLC training tools sale

Reply
 
Thread Tools Display Modes
Old July 12th, 2017, 04:18 PM   #1
mgallgood
Member
United States

mgallgood is offline
 
Join Date: Dec 2016
Location: Tennessee
Posts: 17
RSFactoryTalk View SE VBA to screen print & save as PDF

I'm looking for details on some VBA functionality in FTViewSE. I've been asked to look into programmaticly performing a Print Screen then saving the clipboard content to a file. Preferably a PDF file, but at this point I just need help getting the info out of the clipboard. I can find examples using VBA in Excel but these all use built in Excel image type constants like xlPiture or xlBitmap. Since this is not running in Excel, but in FTV, I'm thinking those won't work, but I could be wrong.

The general question, is there a FTViewSE VBA Programmer's Guide (manual) on the web somewhere that it can be downloaded? Having access to documentation on the FTView object model would be helpful in this and other tasks.

More specifically, can anyone provide some specifics on how to accomplish this task?

Thanks,
Mike
  Reply With Quote
Old July 12th, 2017, 04:30 PM   #2
labeledas
Member
Canada

labeledas is offline
 
labeledas's Avatar
 
Join Date: Apr 2010
Location: Peace River Alberta
Posts: 449
have you tried using a pdf printer like bullzip as the default print and just print the screen to it. Object browser iv Ftview VBA window show you all available objects and properties
  Reply With Quote
Old July 13th, 2017, 01:32 AM   #3
crawler009
Member
Switzerland

crawler009 is offline
 
crawler009's Avatar
 
Join Date: Feb 2012
Location: Planet Earth
Posts: 99
you could call a external program which make the printscreen and saves it to a file. CmdCaptureWin.exe is one of theese.

For example:
Dim sTimestamp As String
sTimestamp = Format(Now(), "yyyymmddhhnnss")
Call Shell("C:\CmdCaptureWin.exe /f Screenshot_" & sTimestamp & ".png /d C:\Screenshots\")
  Reply With Quote
Old July 14th, 2017, 01:36 PM   #4
mgallgood
Member
United States

mgallgood is offline
 
Join Date: Dec 2016
Location: Tennessee
Posts: 17
A follow up.
I have the code working to perform the PrtScrn and then write the clipboard contents to a jpeg file (using the Shell command to launch MS Paint).

At this point I still need to figure out how to send the jpeg to a PDF Printer or otherwise generate the PDF file. Since VBA does not have a Printer object I'm wondering if this is possible.

To narrow the focus a bit, here are two questions:
1) Since I have MSPaint open and have the TaskID (returned from the Shell command), is there a way to utilize this to have Paint print the doc to a PDF file?

2) With a jpeg file now existing, is there a way to simply send it to the PDF Printer directly?

Thanks.
  Reply With Quote
Old July 14th, 2017, 02:02 PM   #5
labeledas
Member
Canada

labeledas is offline
 
labeledas's Avatar
 
Join Date: Apr 2010
Location: Peace River Alberta
Posts: 449
I don't have FTView in front of me but I am wondering if there is an ActiveX printer object that could control with the Invoke method
  Reply With Quote
Old July 14th, 2017, 02:19 PM   #6
labeledas
Member
Canada

labeledas is offline
 
labeledas's Avatar
 
Join Date: Apr 2010
Location: Peace River Alberta
Posts: 449
This might do the trick it has a command line interface and should be able to go from .jpg to pdf
  Reply With Quote
Old July 14th, 2017, 03:24 PM   #7
mgallgood
Member
United States

mgallgood is offline
 
Join Date: Dec 2016
Location: Tennessee
Posts: 17
I got it to work by issuing a "Ctrl-P" and then an "Alt-P" key sequences while Paint was still open. This solution is a little hokey but it works. Prior to this I'm setting the file name for the PDF printer to use (in the registry) so it knows how to name it and where to put it. There are a few delays that will need to be adjusted between the various key sequences used. I'm guessing those will be dependent upon the loading of the machine, but as long as they are long enough to allow the various dialogs to present then I think it will work.

Thanks.
  Reply With Quote
Old July 17th, 2017, 01:40 AM   #8
crawler009
Member
Switzerland

crawler009 is offline
 
crawler009's Avatar
 
Join Date: Feb 2012
Location: Planet Earth
Posts: 99
Quote:
Originally Posted by mgallgood View Post
I got it to work by issuing a "Ctrl-P" and then an "Alt-P" key sequences while Paint was still open. This solution is a little hokey but it works. Prior to this I'm setting the file name for the PDF printer to use (in the registry) so it knows how to name it and where to put it. There are a few delays that will need to be adjusted between the various key sequences used. I'm guessing those will be dependent upon the loading of the machine, but as long as they are long enough to allow the various dialogs to present then I think it will work.

Thanks.
you could do it, but its way to error-prone. What if someone presses a key oder mouse button during that process. Sure it wont work.
Just use a pdf printer which u can control from command promt, for example PDFCreator. Take a screenshot with a command, save the .jpg or .png and send it to the pdf printer.
  Reply With Quote
Old July 17th, 2017, 11:52 AM   #9
mgallgood
Member
United States

mgallgood is offline
 
Join Date: Dec 2016
Location: Tennessee
Posts: 17
Quote:
Originally Posted by crawler009 View Post
you could do it, but its way to error-prone. What if someone presses a key oder mouse button during that process. Sure it wont work.
Just use a pdf printer which u can control from command promt, for example PDFCreator. Take a screenshot with a command, save the .jpg or .png and send it to the pdf printer.
I'm sure it won't, but this was an afterthought on the project and I was only asked to step in and look at this without spending a lot of time. They already had some of this code in place on another FVTiewSE system so I hijacked that and modified it just a bit so it isn't like they don't already have that issue elsewhere, and are OK with it. Plus this functionality is simply to generate a PDF of a screen cap of the View screen. It is not a critical function. Additionally it only takes a couple of seconds to run and then Paint is terminated so even if they deliberately start punching keys and cause the PDF to not print then it isn't the end of the world.
  Reply With Quote
Reply
Jump to Live PLC Question and Answer Forum

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Topics
Thread Thread Starter Forum Replies Last Post
Errors on screen load with FT View SE Client dl5051 LIVE PLC Questions And Answers 0 April 24th, 2017 05:21 PM
FactoryTalk View SE Screen Control via PLC LlndPrkr LIVE PLC Questions And Answers 3 July 7th, 2016 05:13 PM
FactoryTalk View SE - VBA - How to Access Object Properties & Animations? Grendizer LIVE PLC Questions And Answers 2 February 17th, 2016 01:38 PM
Writing Data to Tags using VBA and FT View SE AndJH LIVE PLC Questions And Answers 1 July 11th, 2013 09:59 AM
FactoryTalk View SE + VBA help cpriest LIVE PLC Questions And Answers 0 August 1st, 2008 03:27 PM


All times are GMT -5. The time now is 01:27 PM.


.