+ Reply to Thread
Results 1 to 13 of 13

Macros to open and save multiple websites

  1. #1
    Forum Contributor
    Join Date
    01-20-2015
    Location
    NB, Canada
    MS-Off Ver
    365
    Posts
    164

    Macros to open and save multiple websites

    I would like to have a macros that will create json files from a api.
    I manipulated a code i found online that works for a single file, but i want it to be able to get 100+ files
    ideally i could list the sites in a column and a corresponding file name/location in the column next to it.

    Is this possible ?

    Here is the code I was using

    Please Login or Register  to view this content.

  2. #2
    Banned User!
    Join Date
    02-06-2020
    Location
    Iowa City, IA, USA
    MS-Off Ver
    2016 - 365 / 2007
    Posts
    2,014

    Re: Macros to open and save multiple websites

    ok, so what ur doing now is creating a JSON file by using open, and throwing the response text into it. so, expanding on it is easy because it would only require you to add a loop really. so, if ur sites are in col ''a'' and ur desired file locs are in col ''b'', it would essentially be this:
    Please Login or Register  to view this content.
    you did the incredibly difficult part first. using GET and asynchronous responses in coding is much more advanced than a VBA loop. don't ya think? LOL

  3. #3
    Forum Contributor
    Join Date
    01-20-2015
    Location
    NB, Canada
    MS-Off Ver
    365
    Posts
    164

    Re: Macros to open and save multiple websites

    I found the code and just adjusted it to my site and file location.
    I don't have any coding experience, atm.

    I tried running your code but two lines came back with problems

    Capture.JPG

  4. #4
    Banned User!
    Join Date
    02-06-2020
    Location
    Iowa City, IA, USA
    MS-Off Ver
    2016 - 365 / 2007
    Posts
    2,014

    Re: Macros to open and save multiple websites

    The one with the range code in it probably airs because you've got spaces in your data and column a or there's something else that you did because there's nothing wrong with that line. The other line has a double "and it take that out. Sorry

  5. #5
    Banned User!
    Join Date
    02-06-2020
    Location
    Iowa City, IA, USA
    MS-Off Ver
    2016 - 365 / 2007
    Posts
    2,014

    Re: Macros to open and save multiple websites

    the other thing too is that that entire code that I wrote is meant to be put behind the actual sheet not in a module separately otherwise it will cause a problem or it may not it depends on what she you have active at the time you run it if you did put it in a separate module and not behind the sheet

  6. #6
    Forum Contributor
    Join Date
    01-20-2015
    Location
    NB, Canada
    MS-Off Ver
    365
    Posts
    164

    Re: Macros to open and save multiple websites

    Okay so the first line error there was a comma missing after "a1"
    I removed the " on the second line error
    but I get another error on teh open file path line now

    Capture2.JPG

  7. #7
    Banned User!
    Join Date
    02-06-2020
    Location
    Iowa City, IA, USA
    MS-Off Ver
    2016 - 365 / 2007
    Posts
    2,014

    Re: Macros to open and save multiple websites

    Put a opening ( after the word open and a closing (after the variable name. more than likely that's the issue and that's because VBA is not the most reliable language in the world exactly because Microsoft doesn't care and they don't make any money with it it's always had this exact same problem with almost every statement available in the language. I'm guessing that's the problem because there's nothing wrong with the line of code I don't believe

  8. #8
    Forum Contributor
    Join Date
    01-20-2015
    Location
    NB, Canada
    MS-Off Ver
    365
    Posts
    164

    Re: Macros to open and save multiple websites

    No, I could get brackets to work anywhere on that line.
    I attached the file
    Attached Files Attached Files

  9. #9
    Banned User!
    Join Date
    02-06-2020
    Location
    Iowa City, IA, USA
    MS-Off Ver
    2016 - 365 / 2007
    Posts
    2,014

    Re: Macros to open and save multiple websites

    Well I'm on the phone at the moment writing this so those are the only things I can possibly see but when I get back to my computer I'll download it and run it myself and see what the problem is. meanwhile if you find the problem let us know and post it here so people don't waste their time thanks :-)

  10. #10
    Forum Contributor
    Join Date
    01-20-2015
    Location
    NB, Canada
    MS-Off Ver
    365
    Posts
    164

    Re: Macros to open and save multiple websites

    Great, I really do appreciate the help.
    Take your time. There is zero rush.

  11. #11
    Banned User!
    Join Date
    02-06-2020
    Location
    Iowa City, IA, USA
    MS-Off Ver
    2016 - 365 / 2007
    Posts
    2,014

    Re: Macros to open and save multiple websites

    Well that's good because if there was a rush you would miss your deadline LOL

  12. #12
    Banned User!
    Join Date
    02-06-2020
    Location
    Iowa City, IA, USA
    MS-Off Ver
    2016 - 365 / 2007
    Posts
    2,014

    Re: Macros to open and save multiple websites

    the issue is that filepath is NOT a DIR, silly boy! LOL filepath is this:
    Please Login or Register  to view this content.
    that's a FILE. and if you read the KB, that won't fly:

    https://docs.microsoft.com/en-us/off...kdir-statement

    mkdir() makes dirs, by definition. just like if you run it in the shell (CMD prompt / windows). oops!

    so, the correction is:
    Please Login or Register  to view this content.
    the other thing that you should know is that xldown or any of it's companions (xlup, etc..) will not work if there is only one row/col in the specified range being spanned by those properties. so, make sure you have more than one row when running your code, otherwise the file will freeze and die, because it will try to run 65535 rows. or, if it's a 64 bit programs, 130K+ rows, or whatever it is. see the images below for proof of working for me. 1 = where your code put the JSON. 2 = what I see in the VS code IDE. so, there ya go. have a good one. the modified book is also attached.
    Attached Images Attached Images
    Attached Files Attached Files

  13. #13
    Forum Contributor
    Join Date
    01-20-2015
    Location
    NB, Canada
    MS-Off Ver
    365
    Posts
    164

    Re: Macros to open and save multiple websites

    Yes, that makes sense. It was trying to create a folder called alabama-2019.json inside c:/joe
    Thank you for your help sir.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Macro: Auto Open/Login to Websites
    By Jim Clayton in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-14-2018, 12:42 AM
  2. Data not updated after clicking on Save button in some websites
    By Vidya Sagar H J in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-18-2016, 01:09 PM
  3. Replies: 1
    Last Post: 04-29-2016, 11:55 AM
  4. Code to Open Multiple Websites at Once
    By slindfors in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-05-2016, 08:21 AM
  5. Using graphs from websites in macros
    By Tian1 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-24-2012, 02:23 PM
  6. Open New Workbook with VBA & Save Name & Location for Use in Other Macros
    By amyxkatexx in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 08-03-2010, 02:26 PM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1