+ Reply to Thread
Results 1 to 7 of 7

How to use a Windows API function in a VBS file?

  1. #1
    Forum Expert JasperD's Avatar
    Join Date
    05-07-2013
    Location
    Netherlands
    MS-Off Ver
    Excel 2016
    Posts
    1,393

    How to use a Windows API function in a VBS file?

    Hi all,

    I have the following simple code - I want to run this outside of office applications in a VBS file.
    Can I? If so, how?

    Please Login or Register  to view this content.
    Just running this as VBS won't work, because the URLmon function can't be declared in VBS. So is that possible? I suspect it is, but wouldn't know how.
    Thanks for any help.
    Last edited by JasperD; 04-25-2018 at 05:00 AM.

  2. #2
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Re: How to use a Windows API function in a VBS file?


    Hi !

    Impossible without installing a dll wrapper you must trust in as it can be a security issue in your system …

  3. #3
    Forum Expert JasperD's Avatar
    Join Date
    05-07-2013
    Location
    Netherlands
    MS-Off Ver
    Excel 2016
    Posts
    1,393

    Re: How to use a Windows API function in a VBS file?

    Thanks for the quick and clear answer.

  4. #4
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Re: How to use a Windows API function in a VBS file?


    Better than a dll wrapper is to just use a workaround !
    As a web request can load the file in memory then you can save it where you need …

  5. #5
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,900

    Re: How to use a Windows API function in a VBS file?

    https://msdn.microsoft.com/en-us/lib...(v=vs.85).aspx
    And a good vbs editor
    https://www.vbsedit.com/
    You can use it as free tool but then you need to accept the messages and waits but it's a great tool
    ---
    Hans
    "IT" Always crosses your path!
    May the (vba) code be with you... if it isn't; start debugging!
    If you like my answer, Click the * below to say thank-you

  6. #6
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Re: How to use a Windows API function in a VBS file?


    Thanks for the rep' and well done for achieving the workaround !

  7. #7
    Forum Expert JasperD's Avatar
    Join Date
    05-07-2013
    Location
    Netherlands
    MS-Off Ver
    Excel 2016
    Posts
    1,393

    Re: How to use a Windows API function in a VBS file?

    Hey Marc, actually the work-around didn't solve it. This is related to this thread.

    I have 4 different approaches to get data from an internal site;
    MSXML2.XMLHTTP (which I use) throws a "this page is accessing information that is not under its control" message for every request sent.
    MSXML2.ServerXMLHTTP requires username & pass, which I can't hard-code.
    WinHTTP gives me that weird response header size limit was exceeded error.
    And URLDownloadtoFileA works, but is a-synchronous.

    So I tried to put URLDownloadtofileA into a VBS file, but as mentioned, that won't work.
    When I use XMLHTTP, I *thought* I didn't get a warning, but after clearing my cache and temp folder, it shows it again.

    So - work-around works for 'data pull purposes', but not for 'data pull without bs errors' purposes
    The quest continues...

+ 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. Excel VBA Function Method API Windows Function User32.dll Alias Declare Library List . :)
    By Doc.AElstein in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 01-17-2018, 07:51 PM
  2. Everything is now a PHP file / Windows 7 & Windows 10
    By dflak in forum Suggestions for Improvement
    Replies: 14
    Last Post: 01-21-2017, 12:47 PM
  3. Replies: 1
    Last Post: 03-14-2016, 12:41 PM
  4. [SOLVED] File Download Name assuming Thread Title as File Name Windows 2007
    By jaslake in forum Suggestions for Improvement
    Replies: 10
    Last Post: 03-19-2014, 01:07 PM
  5. Replies: 1
    Last Post: 05-24-2013, 01:35 PM
  6. [SOLVED] Function to check if string is valid/legal windows file name?
    By mc84excel in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-29-2013, 12:42 AM
  7. xlsm file that is saved on Windows 7 platform crashes when opened on Windows XP platform
    By abunchofsmiles in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-25-2012, 11:58 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