The Andrew N. Wiggins Consultancy

Contact me at webmaster@anw.biz

Experimental Site

 

This site designed by Byg Software Ltd

 

The ANW.BIZ Home Page
Up

API

Use an API to open a web-site (Keith: www.kjtfs.com)
 
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" ( _
    ByVal hwnd As Long, _
    ByVal lpOperation As String, _
    ByVal lpFile As String, _
    ByVal lpParameters As String, _
    ByVal lpDirectory As String, _
    ByVal nShowCmd As Long) _
    As Long

Sub OpenWebSite()
Dim lLng_Result As Long
    lLng_Result = ShellExecute(0, "open", "http://www.BygSoftware.com", 0, 0, 1)
End Sub
 
Suppressing Print Preview
 
''From: Jim Rech (jarech@kpmg.com)
''Subject: Re: XL97:Suppressing Print Preview
''
''
''View this article only
''Newsgroups: microsoft.public.Excel.programming
''Date: 2001-03-21 12:16:17 PST
''
'' Found: 11-Apr-2003

Declare Function LockWindowUpdate Lib "user32" (ByVal hwndLock As Long) As Long
Declare Function FindWindowA Lib "user32" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long

Sub SetPageZoom()
    Dim ZoomFactor As Integer
    Dim hwnd As Long

    hwnd = FindWindowA("XLMAIN", Application.Caption)
    LockWindowUpdate hwnd

    With ActiveSheet.PageSetup
            .FitToPagesTall = False
            .FitToPagesWide = 1
            .Zoom = False
    End With
    'in order to calculate the Zoom %,  a PrintPreview must initiated.
    SendKeys "%C"
    ActiveSheet.PrintPreview
    'to get/set the Zoom %, initiate the Page Setup Dialog box.
    SendKeys "P%A~"
    Application.Dialogs(xlDialogPageSetup).show
    ZoomFactor = ActiveSheet.PageSetup.Zoom
    ActiveSheet.PageSetup.Zoom = ZoomFactor

    LockWindowUpdate 0
End Sub

'' ***************************************************************************
'' Purpose  : This version is without the API call
''          : It works, but you get screen flashing ...
'' Written  : 15-Oct-2003 by Andy Wiggins, www.BygSoftware.com
''
Sub SetPageZoom2()
    Dim ZoomFactor As Integer
    Dim hwnd As Long

    Application.ScreenUpdating = False
    With ActiveSheet.PageSetup
            .FitToPagesTall = False
            '.FitToPagesTall = 1
            .FitToPagesWide = 1
            .Zoom = False
    End With
    'in order to calculate the Zoom %,  a PrintPreview must initiated.
    SendKeys "%C"
    ActiveSheet.PrintPreview
    'to get/set the Zoom %, initiate the Page Setup Dialog box.
    SendKeys "P%A~"
    Application.Dialogs(xlDialogPageSetup).show
    ZoomFactor = ActiveSheet.PageSetup.Zoom
    ActiveSheet.PageSetup.Zoom = ZoomFactor
    Application.ScreenUpdating = True

    Debug.Print ZoomFactor

End Sub
 
 
 
   

Published: 17 January 2004
Last edited: 19 May 2008 16:27