Solved

Force GoogleMaps to be visible on the userform

Posted on 2011-02-25
19
256 Views
Last Modified: 2012-05-11
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
Comment
Question by:currentdb
  • 10
  • 9
19 Comments
 
LVL 30

Expert Comment

by:SiddharthRout
Comment Utility
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
 
LVL 1

Author Comment

by:currentdb
Comment Utility
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
 
LVL 30

Expert Comment

by:SiddharthRout
Comment Utility
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
 
LVL 1

Author Comment

by:currentdb
Comment Utility
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
 
LVL 30

Expert Comment

by:SiddharthRout
Comment Utility
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
 
LVL 30

Expert Comment

by:SiddharthRout
Comment Utility
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
 
LVL 1

Author Comment

by:currentdb
Comment Utility
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
 
LVL 1

Author Comment

by:currentdb
Comment Utility
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
 
LVL 30

Expert Comment

by:SiddharthRout
Comment Utility
I think that is possible as well. Let me check...

Sid
0
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 
LVL 1

Author Comment

by:currentdb
Comment Utility
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
 
LVL 30

Accepted Solution

by:
SiddharthRout earned 500 total points
Comment Utility
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
 
LVL 1

Author Comment

by:currentdb
Comment Utility
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
 
LVL 30

Expert Comment

by:SiddharthRout
Comment Utility
Just remove the line

showTitleBar Me

In Private Sub btnPrint_Click()

Sid
0
 
LVL 1

Author Comment

by:currentdb
Comment Utility
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
 
LVL 30

Expert Comment

by:SiddharthRout
Comment Utility
It should only print 1 copy. If you see the pdf, there is only one page.

Sid
0
 
LVL 1

Author Comment

by:currentdb
Comment Utility
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
 
LVL 30

Expert Comment

by:SiddharthRout
Comment Utility
Is the 2nd page blank?
0
 
LVL 1

Author Comment

by:currentdb
Comment Utility
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
 
LVL 1

Author Closing Comment

by:currentdb
Comment Utility
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Dealing with unintended Excel Active-X resizing quirks (VBA code simulates "self correction") David Miller (dlmille) Intro Not everyone is a fan of Active-X controls in spreadsheets (as opposed to the UserForm approach, the older Form controls …
This tutorial explains how to create a series of drop-down lists that are dependent upon prior selections to guide (“force”) the user to make the correct selection and reduce data errors within Microsoft Excel. Excel 2010 was used for this tutorial;…
Viewers will learn the basics of slicers and timelines for both PivotTables and standard Excel tables in Excel 2013.
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.

744 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now