Excel - nombre y tamaño macro qr

 
Vista:
sin imagen de perfil

nombre y tamaño macro qr

Publicado por andres (6 intervenciones) el 08/12/2022 16:28:10
Muy buen dia actualmente tengo un excel el cual genero un qr (con la api de google )en una carpeta , el problema es que no se como poder colocarle el nombre a la imagen que corresponda a la celda B , agradezco cualquier ayuda que me puedan brindar.

--codigo


Function QRCODE(codeText As String)



Dim objXML, Url As String, imgFile As String
Dim xStrImgName As String


Set objXML = CreateObject("Microsoft.XMLHttp")
Url = "https://chart.googleapis.com/chart?chs=250x250&cht=qr&chl=" & codeText
objXML.Open "Get", Url, False
objXML.Send

' quiero que ese range ("b2") sea automático y tome el valor que tenga en la celda

imgFile = CreateObject("wscript.shell").specialfolders("desktop") & "\QR_Imagen\" & _
Format(Now, "yyyymmdd") & Range("b2") & ".png"
With CreateObject("ADODB.Stream")
.Type = 1
.Open
.Write objXML.ResponseBody
.SaveToFile imgFile, 2
.Close
End With
QRCODE = imgFile
End Function
nombre-de-qr
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder
Imágen de perfil de Antoni Masana
Val: 4.908
Oro
Ha mantenido su posición en Excel (en relación al último mes)
Gráfica de Excel

nombre y tamaño macro qr

Publicado por Antoni Masana (2478 intervenciones) el 08/12/2022 17:19:33
Se me ocurre dos soluciones:

Opción 1



- Llamara a la función:

1
=QRCODE(codeText As String, B2 )

- La función:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
Function QRCODE(codeText As String, UPI As String)
    Dim objXML, Url As String, imgFile As String
    Dim xStrImgName As String
 
    Set objXML = CreateObject("Microsoft.XMLHttp")
    Url = "https://chart.googleapis.com/chart?chs=250x250&cht=qr&chl=" & codeText
    objXML.Open "Get", Url, False
    objXML.Send
 
    ' quiero que ese range ("b2") sea automático y tome el valor que tenga en la celda
 
    imgFile = CreateObject("wscript.shell").specialfolders("desktop") & "\QR_Imagen\" & _
              Format(Now, "yyyymmdd") & UPI & ".png"
    With CreateObject("ADODB.Stream")
        .Type = 1
        .Open
        .Write objXML.ResponseBody
        .SaveToFile imgFile, 2
        .Close
    End With
    QRCODE = imgFile
End Function

Opción 2



- Llamara a la función:

1
=QRCODE(codeText As String, Fila() )

- La función:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
Function QRCODE(codeText As String, Fila As String)
    Dim objXML, Url As String, imgFile As String
    Dim xStrImgName As String
 
    Set objXML = CreateObject("Microsoft.XMLHttp")
    Url = "https://chart.googleapis.com/chart?chs=250x250&cht=qr&chl=" & codeText
    objXML.Open "Get", Url, False
    objXML.Send
 
    ' quiero que ese range ("b2") sea automático y tome el valor que tenga en la celda
 
    imgFile = CreateObject("wscript.shell").specialfolders("desktop") & "\QR_Imagen\" & _
              Format(Now, "yyyymmdd") & Range("B" & Fila) & ".png"
    With CreateObject("ADODB.Stream")
        .Type = 1
        .Open
        .Write objXML.ResponseBody
        .SaveToFile imgFile, 2
        .Close
    End With
    QRCODE = imgFile
End Function

Saludos.
\\//_
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
1
Comentar
sin imagen de perfil

nombre y tamaño macro qr

Publicado por andres (6 intervenciones) el 08/12/2022 17:46:50
muchas gracias funciono perfecto
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar