Solved

Force GoogleMaps to be visible on the userform

Posted on 2011-02-25
19
260 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
ID: 34979287
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
ID: 34979313
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
ID: 34979323
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
Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

 
LVL 1

Author Comment

by:currentdb
ID: 34979344
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
ID: 34979363
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
ID: 34979393
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
ID: 34979398
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
ID: 34979487
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
ID: 34979518
I think that is possible as well. Let me check...

Sid
0
 
LVL 1

Author Comment

by:currentdb
ID: 34979600
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
ID: 34979617
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
ID: 34979681
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
ID: 34979823
Just remove the line

showTitleBar Me

In Private Sub btnPrint_Click()

Sid
0
 
LVL 1

Author Comment

by:currentdb
ID: 34979979
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
ID: 34979992
It should only print 1 copy. If you see the pdf, there is only one page.

Sid
0
 
LVL 1

Author Comment

by:currentdb
ID: 34980089
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
ID: 34980161
Is the 2nd page blank?
0
 
LVL 1

Author Comment

by:currentdb
ID: 34980361
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
ID: 34983252
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Improved? Move/Copy Add-in Replacement - How to avoid the annoying, “A formula or sheet you want to move or copy contains the name XXX, which already exists on the destination worksheet.” David Miller (dlmille)  It was one of those days… I wa…
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

820 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