Hi all and thanks for taking a look at this! I have a project I'm doing that I thought was done, but I guess I never should think that way. This was a project that I took pieces from something existing and changed to suit the users request. Basically, it takes a variety of business benchmarks and shows them graphically (I didn't see a way to attach a jpg from my local drive, but I can email a sample if needed). Initially, this was a program that a user would run when they wanted to manually. I got a request to make this where it runs every morning and users can sign up for up to 24 of these "alerts". They would be shown on a jpg (which I converted from a bmp in my program) which would be attached to an email that the user would get. As I mentioned, it looked to work spiffy and I thought I was done, but instead of running it on my local PC for testing, I put it out for live. As it turns out, there is no graphic to the jpg now. I am thinking that it must have needed an active screen to use for a screen print in the picturebox. It works great when I test locally, but no graphic output when run from a server. I have also tried to run it from my PC when my PC is locked (scheduled tasks), and it also gives me a blank picture. It seems like it wants a monitor to be on when it runs and unfortunately I can't do this that way because it will run from a server. In a nutshell...it works great when I run it myself on my PC, but if there is no monitor showing the program running, I get no picture saved. I have been searching all over trying to find an alternative to getting the graphic to work, but so far no luck. I have the code shown below where I save the picturebox. Does anyone have any other ideas as to how I could get what I need saved to use in an email? I haven't done much with pictureboxes, so sorry if I don't sound to knowledgeable. If you need ANY other info, please ask!! Thanks for your time and any help you can offer!!! Kurt CODEPublic Sub SaveFormImageToFile(ByRef ContainerForm As Form, _ ByRef PictureBoxControl As PictureBox, _ ByVal ImageFileName As String) Dim FormInsideWidth As Long Dim FormInsideHeight As Long Dim PictureBoxLeft As Long Dim PictureBoxTop As Long Dim PictureBoxWidth As Long Dim PictureBoxHeight As Long Dim FormAutoRedrawValue As Boolean With PictureBoxControl 'Set PictureBox properties .Visible = False ' was originally false .AutoRedraw = True .Appearance = 0 ' Flat .AutoSize = False .BorderStyle = 0 'No border 'Store PictureBox Original Size and location Values PictureBoxHeight = .Height: PictureBoxWidth = .Width PictureBoxLeft = .Left: PictureBoxTop = .Top 'Make PictureBox to size to inside of form. .Align = vbAlignTop: .Align = vbAlignLeft DoEvents FormInsideHeight = .Height: FormInsideWidth = .Width 'Restore PictureBox Original Size and location Values .Align = vbAlignNone .Height = FormInsideHeight: .Width = FormInsideWidth .Left = PictureBoxLeft: .Top = PictureBoxTop FormAutoRedrawValue = ContainerForm.AutoRedraw ContainerForm.AutoRedraw = True DoEvents 'Copy Form Image to Picture Box BitBlt .hdc, 0, 0, _ FormInsideWidth / Screen.TwipsPerPixelX, _ FormInsideHeight / Screen.TwipsPerPixelY, _ ContainerForm.hdc, 0, 0, _ vbSrcCopy DoEvents SavePicture .Image, ImageFileName DoEvents ContainerForm.AutoRedraw = FormAutoRedrawValue DoEvents End With End Sub |
|