• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 276
  • Last Modified:

Force GoogleMaps to be visible on the userform

Hi all,

My userform contains a map for any address location. When I send the userform to the printer, the GoogleMaps is not visible on the userform. I know I can print it separately, but is there any way to make it visible on the userform ?

Here is the code for the print button. At least it will print every field on the userform, but I don't know why it does not print the GoogleMaps itself.

Thanks for any help you can provide
Cheers
currentdb
Private Sub btnPrint_Click()
  Me.PrintForm
End Sub

Open in new window

0
currentdb
Asked:
currentdb
  • 10
  • 9
1 Solution
 
SiddharthRoutCommented:
It works for me. Are you sure there is an image in the image control when you are issuing the command Me.PrintForm?

Sid
0
 
currentdbAuthor Commented:
Hi Sid,

Yes there's an image in the image control, but it's nowhere to be seen when it's printed on paper. There's not even any white space, nothing. It's like the control is invisible or maybe the printer is blind..:)
0
 
SiddharthRoutCommented:
Do you have a pdf printer? Try printing it to that? Does it show? If not then upload your workbook here. let me test it.

Sid
0
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.

 
currentdbAuthor Commented:
Pdf printer = not real printer ? :) no I don't have it.

Sure here's the workbook. I hope your printer is not blind as mine lol
currentdb-v5a.xlsm
0
 
SiddharthRoutCommented:
No your printer is not blind ;)

You are using a webbrowser and not a Image control as I thought.

Let me have a look at it.

Sid
0
 
SiddharthRoutCommented:
Ok, the answer to your question lies in the other thread ;)

Use the code that I gave in

http://www.experts-exchange.com/Software/Office_Productivity/Office_Suites/MS_Office/Excel/Q_26847470.html#a34979343

Here is the updated workbook.

I have tested it and it works :)

Sid
Currentdb-v5a.xlsm
Book2.pdf
0
 
currentdbAuthor Commented:
Yes because I had to use it as per Helen's exemple (was modified by Rory) if you remember the other thread where I mistakenly split my points :)
0
 
currentdbAuthor Commented:
You are right that works :)

On the other side, I noticed that you inserted the code you already provided in the other question. I was about to insert it along the other code already present in the module, but you were faster than me :)

Is there another way to print it ? Actually if I understand from the printer button, it prints a snapshot of the entire form and that includes the ''X'' (where you can close the form). Is there a way just not to make it visible on the paper ?
0
 
SiddharthRoutCommented:
I think that is possible as well. Let me check...

Sid
0
 
currentdbAuthor Commented:
I hope this one is not too complex as the code before (the one that was in the print button), was the easiest one. It was not hard to write a single line :)
0
 
SiddharthRoutCommented:
Ok since you are already using a "Quit" button.

Would this help? Sample Attached.

Sid

Additional Code Used

In Module

Option Explicit

Public Const GWL_STYLE = -16
Public Const WS_CAPTION = &HC00000
Public Declare Function GetWindowLong _
                       Lib "user32" Alias "GetWindowLongA" ( _
                       ByVal hWnd As Long, _
                       ByVal nIndex As Long) As Long
Public Declare Function SetWindowLong _
                       Lib "user32" Alias "SetWindowLongA" ( _
                       ByVal hWnd As Long, _
                       ByVal nIndex As Long, _
                       ByVal dwNewLong As Long) As Long
Public Declare Function DrawMenuBar _
                       Lib "user32" ( _
                       ByVal hWnd As Long) As Long
Public Declare Function FindWindowA _
                       Lib "user32" (ByVal lpClassName As String, _
                       ByVal lpWindowName As String) As Long
Public lFrmHdl As Long, lngWindow As Long
Sub Form_Show()
    Application.Visible = False
    Application.OnTime Now, "Form_Close"
    UserForm1.Show
End Sub
Sub Form_Close()
    Dim datWaitTime As Date
    datWaitTime = TimeSerial(Hour(Now()), Minute(Now()), Second(Now()) + 3)
    Application.Wait datWaitTime
    Unload UserForm1
    Application.Visible = True
End Sub
Sub HideTitleBar(frm As Object)
    lFrmHdl = FindWindowA(vbNullString, frm.Caption)
    lngWindow = GetWindowLong(lFrmHdl, GWL_STYLE)
    lngWindow = lngWindow And (Not WS_CAPTION)
    Call SetWindowLong(lFrmHdl, GWL_STYLE, lngWindow)
    Call DrawMenuBar(lFrmHdl)
End Sub

Open in new window


In Form

Private Sub UserForm_Initialize()
    HideTitleBar Me
End Sub

Open in new window


Currentdb-v5a.xlsm
0
 
currentdbAuthor Commented:
If the ''Quit'' button remains on the userforms, it makes sense to remove the X.

Just tested it, but ran into a compile error ''Sub not defined'' on the btnPrint. It just highlights this line "Private Sub btnPrint_Click()". I just tried to print and that's why the compile error came in. I looked at the code and everything seems to be ok. Maybe one variable is missing somewhere that was not declared yet.

And
0
 
SiddharthRoutCommented:
Just remove the line

showTitleBar Me

In Private Sub btnPrint_Click()

Sid
0
 
currentdbAuthor Commented:
Just answered in the other question lol

About these 2 lines:
ActiveSheet.PageSetup.Orientation = xlLandscape
ActiveWindow.SelectedSheets.PrintOut Copies:=1

Second line PrintOut Copies:=1, are you sure it prints just one copy ? My printer (not blind now lol) just coughed 2 copies instead of one. It's weird because the form does not exceed yet the mininal requirement on the right margins.

First line, ActiveSheet.PageSetup.Orientation = xlLandscape
I'm trying to change so it can print in normal mode (portrait) which means it changes to ActiveSheet.PageSetup.Orientation = xlPortrait ?

0
 
SiddharthRoutCommented:
It should only print 1 copy. If you see the pdf, there is only one page.

Sid
0
 
currentdbAuthor Commented:
Yes saw only one pdf page as you mentioned. Now changed it to normal (Portrait). Just to compare between Landscape and Portrait...maybe I have to check the controls somewhere to set the margins to their minimum cause that's why it prints on 2 pages.
0
 
SiddharthRoutCommented:
Is the 2nd page blank?
0
 
currentdbAuthor Commented:
No, it's just part of the userform. It's like when you print an Excel worksheet and it exceeds by some margins outside of normal print area.
It's same thing here. Just looked through the code, but there is no any way to set margins to minimum, maybe 0,5 to right and left, same for up and down margins.

If you print a worksheet, you can set these margins as you wish, but in an userform, I don't know how :(
0
 
currentdbAuthor Commented:
Thank you so much for your help. You should be ranked as great master between the ancient masters like Da Vinci, Aristotle, etc :)
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.

  • 10
  • 9
Tackle projects and never again get stuck behind a technical roadblock.
Join Now