Macro does not work on OneDrive. It only works in local folder

%3CLINGO-SUB%20id%3D%22lingo-sub-1390551%22%20slang%3D%22es-ES%22%3EMacro%20does%20not%20work%20on%20OneDrive.%20It%20only%20works%20in%20local%20folder%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1390551%22%20slang%3D%22es-ES%22%3E%3CP%3EGood%20to%20all%2C%20I%20need%20help%20with%20a%20macro%20that%20at%20the%20time%20of%20executing%20a%20command%20when%20I%20have%20the%20files%20loaded%20in%20a%20folder%20in%20Onedrive%20it%20does%20not%20run%2C%20but%20when%20I%20have%20all%20in%20a%20folder%20locally%20it%20takes%20them%20and%20super%20runs%20well.%20And%20now%20I%20need%20that%20it%20can%20be%20run%20from%20Onedrive%20since%20I%20have%20to%20share%20it%20with%20my%20boss%20and%20his%20boss%20and%20the%20file%20is%20changing%20day%20by%20day.%20Thank%20you%20very%20much%20and%20I%20hope%20someone%20can%20help%20me%3C%2FP%3E%3CP%3EThe%20code%20I%20have%20for%20the%20routes%20is%20the%20following%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%20class%3D%22%22%3ERuta_Personas%20-%20ActiveWorkbook.Path%20%26amp%3B%20%22'Images'%2C%20'People'%2C%20''%2C%20''%2C%20''The's'.%3C%2FP%3E%3CP%3ERuta_Alertas%20-%20ActiveWorkbook.Path%20%26amp%3B%20%22'Images'%2FAlerts'%22%3C%2FP%3E%3CP%3ERuta_Clientes%20-%20ActiveWorkbook.Path%20%26amp%3B%20%22'Images'%2FCustomers'%22%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E__________________%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Eand%20part%20of%20the%20spread%20is%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%20class%3D%22%22%3EFunction%20cargar_perfil(value%20As%20String%2C%20lbl_nombre%20As%20Object%2C%20lbl_apellido%20As%20Object%2C%20lbl_TerminoS%20As%20Object%2C%20lbl_rol%20As%20Object%2C%20lbl_dias_vacaciones%20As%20Object%2C%20_%3C%2FP%3E%3CP%3E%26nbsp%3Blbl_contraparte%20As%20Object%2C%20lbl_antiguedad%20As%20Object%2C%20img_persona%20As%20Variant%2C%20img_cliente%20As%20Variant%2C%20_%3C%2FP%3E%3CP%3E%26nbsp%3Bimg_alerta_servicio%20As%20Variant%2C%20img_alerta_token%20As%20Variant%2C%20img_alerta_vacaciones%20As%20Variant%2C%20img_cumpleanos%20As%20Variant)%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EDim%20lookuprange2%20As%20Range%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EDim%20location%20As%20String%2C%20location2%20As%20String%2C%20apellido_paterno%20As%20String%2C%20apellido_materno%20As%20String%2C%20_%3C%2FP%3E%3CP%3Eas%20String%20path%2C%20pathimagen2%20As%20String%2C%20pathimagen3%20As%20String%2C%20pathimagen4%20As%20String%2C%20_%3C%2FP%3E%3CP%3Epathimagen5%20As%20String%2C%20pathimagen6%20As%20String%2C%20num_dias_vacaciones%20As%20Integer%2C%20_%3C%2FP%3E%3CP%3Enum_a%C3%B1os%20As%20Integer%2C%20plural_singular%20As%20String%2C%20_%3C%2FP%3E%3CP%3Elocation%20As%20String%2C%20num_alerta%20As%20Variant%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EDim%20lookuprange%20As%20Range%2C%20Ruta_Personas%2C%20Ruta_Alertas%2C%20Ruta_Clientes%3C%2FP%3E%3CP%3ESet%20lookuprange%20%3F%20ThisWorkbook.Sheets(%22BBDD_General%22).%20Range(%22B1%3ACC100%22)%20'range%20to%20search%20for%3C%2FP%3E%3CP%3ESet%20lookuprange2%20%3F%20ThisWorkbook.Sheets(%22BBDD_General%22).%20Range(%22B1%3ACC1%22)%20'%20First%20column%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%3E%3CSTRONG%3E%26nbsp%3B%20%26nbsp%3B%20Ruta_Personas%20-%20ActiveWorkbook.Path%20%26amp%3B%20%22'Images'%2C%20'People'%2C%20''%2C%20''%2C%20''The's'.%3C%2FSTRONG%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%3E%3CSTRONG%3E%26nbsp%3B%20%26nbsp%3B%20Ruta_Alertas%20-%20ActiveWorkbook.Path%20%26amp%3B%20%22'Images'%2FAlerts'%22%3C%2FSTRONG%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%3E%3CSTRONG%3E%26nbsp%3B%20%26nbsp%3B%20Ruta_Clientes%20-%20ActiveWorkbook.Path%20%26amp%3B%20%22'Images'%2FCustomers'%22%3C%2FSTRONG%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20'Next%20function%20to%20assign%20person%20name%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20Application.Match(%22Names%22%2C%20lookuprange2%2C%200)%3C%2FP%3E%3CP%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20lbl_nombre.%20Caption%20-%20Application.VLookup(value%2C%20lookuprange%2C%20location%2C%20False)%3C%2FP%3E%3CP%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20Location%20-%20Empty%3C%2FP%3E%3CP%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20'Next%20function%20to%20assign%20last%20name%20person%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20Location%20-%20Application.Match(%22Apellido_Paterno%22%2C%20lookuprange2%2C%200)%3C%2FP%3E%3CP%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20location2%20-%20Application.Match(%22Apellido_Materno%22%2C%20lookuprange2%2C%200)%3C%2FP%3E%3CP%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20apellido_paterno%20-%20Application.VLookup(value%2C%20lookuprange%2C%20location%2C%20False)%3C%2FP%3E%3CP%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20apellido_materno%20-%20Application.VLookup(value%2C%20lookuprange%2C%20location2%2C%20False)%3C%2FP%3E%3CP%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20lbl_apellido.%20Caption%20-%20apellido_paterno%20%26amp%3B%20apellido_materno%3C%2FP%3E%3CP%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20Location%20-%20Empty%3C%2FP%3E%3CP%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20Location2%20-%20Empty%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20'Next%20function%20to%20assign%20photo%20person%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20Location%20-%20Application.Match(%22Nombre_Persona%22%2C%20lookuprange2%2C%200)%3C%2FP%3E%3CP%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20pathimage%20.%20Ruta_Personas%20%26amp%3B%20Application.VLookup(value%2C%20lookuprange%2C%20location%2C%20False)%20%26amp%3B%20%22.png%22%3C%2FP%3E%3CP%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B'img_persona.%20Fill.UserPicture%20(image%20path)%3C%2FP%3E%3CP%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20If%20Dir(pathimage%2C%20vbDirectory)%20%26lt%3B%26gt%3B%20%22%22%20Then%3C%2FP%3E%3CP%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20img_persona.%20Fill.UserPicture%20(image%20path)%3C%2FP%3E%3CP%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20Else%3C%2FP%3E%3CP%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20Location%20-%20Application.Match(%22Sex%22%2C%20lookuprange2%2C%200)%3C%2FP%3E%3CP%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20pathimage%20.%20Ruta_Personas%20%26amp%3B%20Application.VLookup(value%2C%20lookuprange%2C%20location%2C%20False)%20%26amp%3B%20%22.png%22%3C%2FP%3E%3CP%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20img_persona.%20Fill.UserPicture%20(image%20path)%3C%2FP%3E%3CP%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20End%20If%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1390551%22%20slang%3D%22es-ES%22%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EFormulas%20and%20functions%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EMacros%20and%20VBA%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EOffice%20365%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1399079%22%20slang%3D%22en-US%22%3ERe%3A%20Macro%20does%20not%20work%20on%20OneDrive.%20It%20only%20works%20in%20local%20folder%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1399079%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F668358%22%20target%3D%22_blank%22%3E%40Guille_Pazos%3C%2FA%3E%26nbsp%3B%20I'm%20struggling%20with%20a%20similar%20problem%20with%20saving%20items%20on%20sharepoint.%26nbsp%3B%20I%20believe%20the%20problem%20is%20that%20the%20path%20is%20an%20explorer%2FOS%20type%20of%20action%20while%20sharepoint%2Fonedrive%20is%20driven%20through%20web%20api.%26nbsp%3B%20I%20have%20been%20able%20to%20make%20it%20work%20if%20I%20map%20a%20local%20drive%20to%20the%20sharepoint%2Fonedrive%20location%2C%20but%20have%20no%20guarantee%20my%20colleagues%20have%20that%20drive%20mapped.%26nbsp%3B%20I%20have%20tried%20forcing%20a%20drive%20to%20get%20mapped%2C%20but%20haven't%20gotten%20that%20working%20right%20yet%20either%20(still%20trying).%26nbsp%3B%20I%20have%20also%20been%20able%20to%20changing%20the%20path%20from%3A%3C%2FP%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fname.sharepoint.com%2Fpath...%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fname.sharepoint.com%2Fpath...%26nbsp%3B%3C%2FA%3E%3C%2FP%3E%3CP%3Eto%3C%2FP%3E%3CP%3E%5C%5Cname.sharepoint.com%40SSL%5Cpath...%3C%2FP%3E%3CP%3Ebut%20that%20only%20works%20if%20I%20have%20that%20server%20marked%20as%20a%20trusted%20server%20through%20IE%3C%2FP%3E%3CP%3EI%20don't%20know%20if%20any%20of%20that%20is%20of%20help%20but%20I%20will%20keep%20an%20eye%20here%20to%20see%20anyone%20else%20has%20more%20help%3C%2FP%3E%3C%2FLINGO-BODY%3E
Occasional Visitor

Good to all, I need help with a macro that at the time of executing a command when I have the files loaded in a folder in Onedrive it does not run, but when I have all in a folder locally it takes them and runs super well. And now I need that it can be run from Onedrive since I have to share it with my boss and his boss and the file is changing day by day. Thank you very much and I hope someone can help me

The code I have for the routes is the following:

 

Ruta_Personas = ActiveWorkbook.Path & "\Imagenes\Personas\"

Ruta_Alertas = ActiveWorkbook.Path & "\Imagenes\Alertas\"

Ruta_Clientes = ActiveWorkbook.Path & "\Imagenes\Clientes\"

 

__________________

 

y parte del extendido es:

 

Function cargar_perfil(value As String, lbl_nombre As Object, lbl_apellido As Object, lbl_TerminoS As Object, lbl_rol As Object, lbl_dias_vacaciones As Object, _

 lbl_contraparte As Object, lbl_antiguedad As Object, img_persona As Variant, img_cliente As Variant, _

 img_alerta_servicio As Variant, img_alerta_token As Variant, img_alerta_vacaciones As Variant, img_cumpleanos As Variant)

 

Dim lookuprange2 As Range

 

Dim ubicacion As String, ubicacion2 As String, apellido_paterno As String, apellido_materno As String, _

rutaimagen As String, rutaimagen2 As String, rutaimagen3 As String, rutaimagen4 As String, _

rutaimagen5 As String, rutaimagen6 As String, num_dias_vacaciones As Integer, _

num_años As Integer, plural_singular As String, _

ubicación As String, num_alerta As Variant

 

Dim lookuprange As Range, Ruta_Personas, Ruta_Alertas, Ruta_Clientes

Set lookuprange = ThisWorkbook.Sheets("BBDD_General").Range("B1:CC100") 'rango donde buscar

Set lookuprange2 = ThisWorkbook.Sheets("BBDD_General").Range("B1:CC1") ' Primera columna

 

    Ruta_Personas = ActiveWorkbook.Path & "\Imagenes\Personas\"

    Ruta_Alertas = ActiveWorkbook.Path & "\Imagenes\Alertas\"

    Ruta_Clientes = ActiveWorkbook.Path & "\Imagenes\Clientes\"

 

        'Siguiente función para asignar nombre persona:

            ubicacion = Application.Match("Nombres", lookuprange2, 0)

            lbl_nombre.Caption = Application.VLookup(value, lookuprange, ubicacion, False)

            ubicacion = Empty

        'Siguiente función para asignar apellido persona:

            ubicacion = Application.Match("Apellido_Paterno", lookuprange2, 0)

            ubicacion2 = Application.Match("Apellido_Materno", lookuprange2, 0)

            apellido_paterno = Application.VLookup(value, lookuprange, ubicacion, False)

            apellido_materno = Application.VLookup(value, lookuprange, ubicacion2, False)

            lbl_apellido.Caption = apellido_paterno & apellido_materno

            ubicacion = Empty

            ubicacion2 = Empty

 

        'Siguiente función para asignar foto persona:

 

            ubicacion = Application.Match("Nombre_Persona", lookuprange2, 0)

            rutaimagen = Ruta_Personas & Application.VLookup(value, lookuprange, ubicacion, False) & ".png"

           ' img_persona.Fill.UserPicture (rutaimagen)

            If Dir(rutaimagen, vbDirectory) <> "" Then

            img_persona.Fill.UserPicture (rutaimagen)

            Else

            ubicacion = Application.Match("Sexo", lookuprange2, 0)

            rutaimagen = Ruta_Personas & Application.VLookup(value, lookuprange, ubicacion, False) & ".png"

            img_persona.Fill.UserPicture (rutaimagen)

            End If

 

Thanks

3 Replies

@Guille_Pazos  I'm struggling with a similar problem with saving items on sharepoint.  I believe the problem is that the path is an explorer/OS type of action while sharepoint/onedrive is driven through web api.  I have been able to make it work if I map a local drive to the sharepoint/onedrive location, but have no guarantee my colleagues have that drive mapped.  I have tried forcing a drive to get mapped, but haven't gotten that working right yet either (still trying).  I have also been able to changing the path from:

https://name.sharepoint.com/path... 

to

\\name.sharepoint.com@SSL\path...

but that only works if I have that server marked as a trusted server through IE

I don't know if any of that is of help but I will keep an eye here to see anyone else has more help

I am having a similar problem. Activeworkbook.Path shows https://mysp-cloud.kp.org/personal/.. .instead of C:\Users\<USERID>\OneDrive - <ORGNAME> ...