Propósito

✔ Programação GLOBAL® - Quaisquer soluções e/ou desenvolvimento de aplicações pessoais, ou da empresa, que não constem neste Blog devem ser tratados como consultoria freelance. Queiram contatar-nos: brazilsalesforceeffectiveness@gmail.com | ESTE BLOG NÃO SE RESPONSABILIZA POR QUAISQUER DANOS PROVENIENTES DO USO DOS CÓDIGOS AQUI POSTADOS EM APLICAÇÕES PESSOAIS OU DE TERCEIROS.

.: Vitrine

Carregando artigos...

Views

Mostrando postagens com marcador converter. Mostrar todas as postagens
Mostrando postagens com marcador converter. Mostrar todas as postagens

PIECE OF CAKE - Convertendo Texto em Imagem - Convert Text to an Image using the VBA Windows API


Nesta época de Mídias Sociais e grande necessidade de publicarmos KPIs e Dashboards com insights baseados em informações atualizadas, termos uma solução como a demonstrada abaixo será muito útil no dia a dia.

Sub PublishExcelRangeAsImage (r As Excel.Range, stFileNamePathForImage As String, Optional stImageType = "BMP")
 '
 ' Copies a range in Excel, converts it to a picture, and saves it as an image file.
 ' r = The range you want to copy and convert to an image.
 ' stFileNamePathForImage = Full path, without the period (.) and extension of the destination file.
 ' stImageType = The extension for the filename; also determines the type of image saved to disk.
 ' stImageType can be "bmp", "gif", or "jpg". "bmp" is default.
 '
 Dim c As Excel.Chart
 Dim wsSave
 Dim wbSave As Excel.Workbook
 Dim fDisplayAlerts As Boolean

 stImageType = UCase(stImageType)
 '
 ' In case another Workbook is active, save it so we can restore it when we are done.
 ' We need to do this because, later, we will change the active sheet to a chart.
 '
 Set wbSave = Excel.ActiveWorkbook
 Set wsSave = wbSave.ActiveSheet
 '
 ' Create a temporary chart object. This is where the image will be created.
 '
 Set c = r.Worksheet.Parent.Charts.Add
 '
 ' In Excel 2007, a new chart is no lonter empty; therefore, clear it.
 '
 c.ChartArea.Clear

 c.ChartArea.Height = r.Height * 2 ' Make sure the ChartArea is bigger than
 c.ChartArea.Width = r.Width * 2 ' the image, or image will be made smaller
 '
 ' Copy the image from the range object to the chart.
 '
 r.CopyPicture xlScreen, xlBitmap
 c.Paste
 '
 ' Position the image, as Excel doesn't do this well on it's own.
 ' Note, since we cleared the chart before pasting the image,
 ' we can be sure that the image is the only shape on the chart.
 ' Thus, we are safe to directly address shape 1, from the shape
 ' collection and know it's the image.
 '
 Let c.Shapes(1).Left = 0
 Let c.Shapes(1).Top = 0
 Let c.Shapes(1).Height = r.Height
 Let c.Shapes(1).Width = r.Width
 '
 ' Prevent the image from resizing when we resize the chart.
 '
 Let c.Shapes(1).Placement = xlFreeFloating
 '
 ' Now make the chart the same size as the image.
 '
 ' We need to activate the chart first because of a timing issue. If we don't
 ' activate it, the code fails when we set the height, unless we put a delay into the code.
 ' Better to activate it than put in a delay.
 '
 c.Activate
 Let c.ChartArea.Height = r.Height
 Let c.ChartArea.Width = r.Width
 '
 ' Save the image as a file.
 '
 c.Export stFileNamePathForImage & "." & stImageType, stImageType
 '
 ' We are done. Delete the chart. Note, we first need to turn off alerts, or else,
 ' Excel prompts us to make sure we really want to delete it.
 '
 Let fDisplayAlerts = Application.DisplayAlerts
 Let Application.DisplayAlerts = False
 c.Delete
 Let Application.DisplayAlerts = fDisplayAlerts

 Set c = Nothing
 '
 ' Return focus back to the original workbook/worksheet that was active
 ' when this code began.
 '
 wsSave.Activate

 Set wbSave = Nothing
 Set wsSave = Nothing

End Sub


#A&A #API #Converter #Dashboard #Imagem #KPI #PIECEOFCAKE #Text #Texto #WindowsAPI #POC #VBA 


Defina a Latitude e a Longitude - Find Latitude and Longitude of any address using Google Map API and VBA


VBA Excel - Traduzindo Planilhas - MS Excel VBA Script to Translate worksheets using the Google Translate API
VBA Excel - Traduzindo Planilhas - MS Excel VBA Script to Translate worksheets using the Google Translate API

Excel - Manipule o Google Maps em sua Planilha - Put a Google Map in your Spreadsheet
Excel - Manipule o Google Maps em sua Planilha - Put a Google Map in your Spreadsheet

Convertendo Texto em Imagem - Convert Text to an Image using the VBA Windows API
Convertendo Texto em Imagem - Convert Text to an Image using the VBA Windows API

Correção de Métricas - For Subscripts, Superscripts and Common Typos
Correção de Métricas - For Subscripts, Superscripts and Common Typos

MS Access - Cinco Formas Manuais de Reparo
MS Access - Cinco Formas Manuais de Reparo

MS Access e MS Word - Técnica de Automação
MS Access e MS Word - Técnica de Automação

Microsoft Access - Removendo Prefixo das Tabelas
Microsoft Access - Removendo Prefixo das Tabelas

Sempre Use Stored Procedures - Always Use Stored Procedures
Sempre Use Stored Procedures - Always Use Stored Procedures

A&A - Dados ou Informações?
A&A - Dados ou Informações?

Consulte-nos

⬛◼◾▪ Social Media ▪◾◼⬛
• FACEBOOK • TWITTER • INSTAGRAM • TUMBLR • GOOGLE+ • LINKEDIN • PINTEREST

⬛◼◾▪ Blogs ▪◾◼⬛ 


⬛◼◾▪ CONTATO ▪

VBA - Convertendo o número do mês no nome por extenso - Convertendo o nome por extenso do mês no número








Blog Office VBA | Blog Excel | Blog Access | 

Hello folks!

Ao lidar com periodicidades móveis como MAT (Moving Annual Total), YTD (Year to Date), QTD (Quarter-To-Date), MTD (Month-To-Date), Year-ending, etc... Talvez necessitemos ajustar os nossos meses movendo-os dinamicamente.
How to convert month number to month name
Convert numbers to month names
Convert Month Name To Number
Convert Month Number to Month Name in Report based on query

A movimentação dos meses ajustada nas apresentações dos gráficos e das tabelas dos nossos Dashboards e Scorecards, invariavelmente requererão que os meses sejam manipulados internamente por somá-los ou subtraí-los, adequando as apresentações dos mesmos. Para que este feito fosse facilmente implementado precisaríamos transformar Novembro em 11 11 em Novembro, por exemplo. Como ?

Para o vosso regalo, seguem funções abaixo:

Function ABL_Convert_Number2MonthName (ByVal lngMonth As Long) As String

    ' Author:                     Date:               Contact:                 URL:

    ' André Bernardes             28/06/2011 13:58    bernardess@gmail.com     http://inanyplace.blogspot.com/

    ' Application: ®

    ' Converte o número do mês no respectivo nome (11 em Novembro).

    ' Listening: 20 - Flynn Lives - Daft Punk - TRON Legacy Soundtrack [Complete Edition](MP3@320Kbps)  

    On Error GoTo Err_GetMonthName

    Dim dteTemp As Date

    If lngMonthName < 1 And lngMonthName > 12 Then

        Let ABL_Convert_Number2MonthName = vbNullString    

        Exit Function

    End If

    Let dteTemp = DateSerial(Year(Date), lngMonth, 1)

    Let ABL_Convert_Number2MonthName = Format(dteTemp, "mmmm")

    Exit Function

Err_GetMonthName:

    Let ABL_Convert_Number2MonthName = vbNullString

End Function

Function ABL_Convert_MonthName2Number (monthName As String) As Integer
    ' Author:                     Date:               Contact:                 URL:

    ' André Bernardes             28/06/2011 14:01    bernardess@gmail.com     http://inanyplace.blogspot.com/

    ' Application: ®

    ' Converte o nome de um mês em número (Novembro em 11).

    ' Listening: 20 - Flynn Lives - Daft Punk - TRON Legacy Soundtrack [Complete Edition](MP3@320Kbps)

    ' try to convert month name to actual date type

    Dim dtestr As String

    Let dtestr = monthName & "/1/2011"

    Dim dte As Date

    On Error Resume Next

    Let dte = CDate(dtestr)

If Err.Number <> 0 Then

  Let ABL_Convert_MonthName2Number = -999

  Exit Function

End If

    On Error GoTo 0

    Let ABL_Convert_MonthName2Number = Month(dte)

End Function

Vocabulário:

YTDYear to Date

QTD = É um período iniciado no começo do trimestre em curso, terminando na data atual.

MAT = Moving Annual Total.

MTD = Month-To-Date


Tags: VBA, Office, Month, Mês, converter

diHITT - Notícias