Consulting

Page 1 of 2 1 2 LastLast
Results 1 to 20 of 38

Thread: Put Country Codes in Excel For SharePoint

  1. #1
    VBAX Regular
    Joined
    Jul 2017
    Posts
    18
    Location

    Put Country Codes in Excel For SharePoint

    Hello everybody,


    This is my issue below.

    I created a macro that creates files. These files are uploaded to a SharePoint library. In this library, 2 variables have a mandatory required field: "Code_File" et "Codes_Countries" :
    * "Code_File": one-dimensional variable with type of files values (ex: "A", "B", "C"...)
    * "Codes_Countries": two-dimensional variable with couples of countries values (ex: "FR, US", "GE, IT", "ES, PT"...)

    As a preamble, I work on the SharePoint with a connection to a network drive.

    My 1st solution was to use custom properties of Excel. I created in a produced file a custom property named "Code_File" with the "A" value. I saved the file on my disk and I copied-pasted it on the SharePoint. The "A" value was read and displayed in the "Code_File" column as well. There's a problem with the "Code_File" variable. I didn't know how encodes 2 codes in a custom property value. So I entered "FR, US". This value is displayed as well on the SharePoint library in the "Code_File" column. But the filter shows that this value is not read correctly. "FR, US" is indeed read as an only string whereas it should be read as "FR" as country code 1 and "US" as country code 2. I tried to input values with other separators, with or without spaces ("FR-US", "FR ; US", "FR_US"...), but there is nothing to do: the value is not read correctly.

    Ma 2nd solution was to save directly the produced file on the SharePoint. It's necessary to make a first save, a test save which generates an error that is handled to display "Content Type Properties" which are also the 2 required variables. Then, I enter a value for each variable, by using in VBA a table with 2 dimensions ("Tab_Codes_Countries(0)" et "Tab_Codes_Countries(1)") to enter the codes of the 2 countries. In the SharePoint library, there are defined lists for each variable, it's necessary to take care of the codes input, with codes that should belong to these lists, without that the final save will trigger an error and the file won't be saved. I also save the file twice, definitively. This time, the filter of the "Codes_Countries" column works as well. To precise, I tested copy-paste the produced file in the SharePoint library and then to open it, to avoid the firts test save that triggers an error. But it takes more time.

    The 2nd solution is satisfactory, but it takes more time than the 1st: about 6-7 sec vs 1-2 sec for 1 file. I produce 900 files, so it's a very important difference.

    * Is it possible, in my first solution, to tag a two-dimensional variable (which requires 2 values) with an Excel custom property?
    * If it's impossible, is there any solution plus rapide et efficace avec VBA que ma 2ème solution ?


    Thanks for your help.

    Best regards.

  2. #2
    Knowledge Base Approver VBAX Wizard
    Joined
    Apr 2012
    Posts
    5,645
    Use the workbook_Open event to split the customproperty tag.

  3. #3
    VBAX Regular
    Joined
    Jul 2017
    Posts
    18
    Location
    Sorry, I don't know what you mean when you say "split the customproperty tag".

  4. #4
    Moderator VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,814
    Location
    : Maybe
    FR, 1
    US, 2
    GE, 3
    etc

    Try different separators, including a Space
    FR. 1
    FR.1
    FR- 1
    FR -1
    FR 1
    FR/1

    As a last resort, read the Manual

    Just a wild guess, but "Codes_Countries" may be the name, no ext, of a plain text file with
    COUNTRY; CODE
    FR; 1
    US; 2
    GE; 3
    etc
    I expect the student to do their homework and find all the errrors I leeve in.


    Please take the time to read the Forum FAQ

  5. #5
    VBAX Regular
    Joined
    Jul 2017
    Posts
    18
    Location
    Sorry, I don't understant what you say for "FR, 1", "US, 2", "GE, 3".

    I tried different seperators, but It doesn't work as well. I noticed that the good seperator seems to be ";", but the 2 codes are not read as well.

  6. #6
    Knowledge Base Approver VBAX Wizard p45cal's Avatar
    Joined
    Oct 2005
    Location
    Surrey UK
    Posts
    5,875
    Quote Originally Posted by mdmackillop View Post
    and
    https://www.excelforum.com/excel-pro...t-library.html
    and
    https://www.mrexcel.com/forum/excel-...t-library.html
    and in French:
    https://forum.excel-pratique.com/exc...ie-t96468.html
    https://www.excel-downloads.com/thre...hier.20018877/
    https://www.developpez.net/forums/d1...point-fichier/
    https://openclassrooms.com/forum/suj...rie-sharepoint

    Cross posting rules are pretty universal across these sites, you should be linking to all of them left, right and centre. Why? Have a read of http://www.excelguru.ca/content.php?184

    Could you give us a screen shot of the problem custom property of a file where it is correct? A bit like:
    Capture3.JPG
    p45cal
    Everyone: If I've helped and you can't be bothered to acknowledge it, I can't be bothered to look at further posts from you.

  7. #7

  8. #8
    VBAX Regular
    Joined
    Jul 2017
    Posts
    18
    Location
    Test

  9. #9
    Knowledge Base Approver VBAX Wizard p45cal's Avatar
    Joined
    Oct 2005
    Location
    Surrey UK
    Posts
    5,875
    Can't see anything at all at that resolution.
    p45cal
    Everyone: If I've helped and you can't be bothered to acknowledge it, I can't be bothered to look at further posts from you.

  10. #10
    VBAX Regular
    Joined
    Jul 2017
    Posts
    18
    Location
    Quote Originally Posted by p45cal View Post
    Can't see anything at all at that resolution.
    -> https://img15.hostingpics.net/pics/947657cccccccccc.png

  11. #11
    Knowledge Base Approver VBAX Wizard p45cal's Avatar
    Joined
    Oct 2005
    Location
    Surrey UK
    Posts
    5,875
    CustomDocumentproperties can't be an array. I tried doing that in VBA but it failed. I even tried setting up a Name in the workbook and putting a text array in that (that bit is easy) and then linking the CustomProperty to tthat name; it allowed me to do that but the CustomDocumentProperty just ended up as #VALUE!.
    I know nothing about Sharepoint. Do the values in the bottom right of your screenshot come from the CustomProperties of the Excel file? If so, then is the name of the custom property an exact match for the column name in SharePoint ("Countries", "Countries ", etc.)?
    If your screenshot is of a working file, it looks as if it is just a plain string like "CY,FC".
    I think you're going to have to trial-and-error it manually until you get the format and name correct, then we can look at automating the process to save the file only once.

    re:"a test save which generates an error that is handled to display "Content Type Properties" which are also the 2 required variables. Then, I enter a value for each variable, by using in VBA a table with 2 dimensions…"
    Where is the code for this process? Can you show it? It may help us work out what to do.
    p45cal
    Everyone: If I've helped and you can't be bothered to acknowledge it, I can't be bothered to look at further posts from you.

  12. #12
    Moderator VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,814
    Location
    And http://www.ozgrid.com/forum/showthread.php?t=204976

    Quote Originally Posted by Air1_16 View Post
    Sorry, I don't understant what you say for "FR, 1", "US, 2", "GE, 3".

    I tried different seperators, but It doesn't work as well. I noticed that the good seperator seems to be ";", but the 2 codes are not read as well.
    A 2-dimensional variable has 2 values
    FR is one part
    1 is the other part

    FR; 1 is an example of a 2-d value. I don't know if that is what SharePoint needs.

    SharePoint Locale Codes: http://howididit-sharepoint.blogspot...ale-codes.html
    I expect the student to do their homework and find all the errrors I leeve in.


    Please take the time to read the Forum FAQ

  13. #13
    VBAX Regular
    Joined
    Jul 2017
    Posts
    18
    Location
    Quote Originally Posted by p45cal View Post
    CustomDocumentproperties can't be an array.
    That's exactly my big problem, and maybe there's no direct solution. Maybe it's possible to find a reliable way.


    Quote Originally Posted by p45cal View Post
    I even tried setting up a Name in the workbook and putting a text array in that (that bit is easy) and then linking the CustomProperty to tthat name; it allowed me to do that but the CustomDocumentProperty just ended up as #VALUE!
    I tried this with 2 cells ("A1" & "A2"). The value of the Custom Property was the value of "A1" cell.


    Quote Originally Posted by p45cal View Post
    I know nothing about Sharepoint. Do the values in the bottom right of your screenshot come from the CustomProperties of the Excel file? If so, then is the name of the custom property an exact match for the column name in SharePoint ("Countries", "Countries ", etc.)?
    You're right. The name of the Custom Property must be the the same as the SharePoint library variable label.



    Quote Originally Posted by p45cal View Post
    If your screenshot is of a working file, it looks as if it is just a plain string like "CY,FC".
    I think you're going to have to trial-and-error it manually until you get the format and name correct, then we can look at automating the process to save the file only once.
    I tried many attempts with differents seperators. ";" seems to be the right seperator. But "CY; FC" is read as one country, and not as the combination of "CY" country" and "FC" country".

  14. #14
    VBAX Regular
    Joined
    Jul 2017
    Posts
    18
    Location
    Quote Originally Posted by p45cal View Post
    re:"a test save which generates an error that is handled to display "Content Type Properties" which are also the 2 required variables. Then, I enter a value for each variable, by using in VBA a table with 2 dimensions…"
    Where is the code for this process? Can you show it? It may help us work out what to do.
    Yan can find my file below:
    filedropper.com/savetagfilesonthesharepoint-v011
    Last edited by Air1_16; 07-26-2017 at 06:36 AM.

  15. #15
    Knowledge Base Approver VBAX Wizard
    Joined
    Apr 2012
    Posts
    5,645
    You can always upload a file here in this forum (the best option)

  16. #16
    VBAX Regular
    Joined
    Jul 2017
    Posts
    18
    Location
    OK, thanks.

    The SharePoint library need 2 countries codes in "Codes_Countries" variable, for example "FR, US".

    I can enter "FR, US" or "FR, 1" in the Custom Property value, this value will always read in the SharePoint library as 1 country, as 1 string.

  17. #17
    Knowledge Base Approver VBAX Wizard
    Joined
    Apr 2012
    Posts
    5,645
    Petitio ad principium.

  18. #18
    Moderator VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,814
    Location
    The SharePoint library need 2 countries codes in "Codes_Countries" variable,
    Maybe it needs one country and one Locale Code. For example
    FR; 1035
    I expect the student to do their homework and find all the errrors I leeve in.


    Please take the time to read the Forum FAQ

  19. #19
    Knowledge Base Approver VBAX Wizard p45cal's Avatar
    Joined
    Oct 2005
    Location
    Surrey UK
    Posts
    5,875
    Quote Originally Posted by Air1_16 View Post
    I'm getting warnings about this site not being secure both in FireFox and Chrome.
    If you can upload/attach here, that would be better.
    p45cal
    Everyone: If I've helped and you can't be bothered to acknowledge it, I can't be bothered to look at further posts from you.

  20. #20
    VBAX Regular
    Joined
    Jul 2017
    Posts
    18
    Location
    For me, it's not a question of code type ("US", "2" or "1035"). The problem is that "FR; 1035" is read as only string. Same thing for "FR; US" and "FR; 2".

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •