+ Reply to Thread
Results 1 to 18 of 18

Is it possible to convert C++ code into VBA

  1. #1
    Valued Forum Contributor
    Join Date
    08-29-2012
    Location
    In lockdown
    MS-Off Ver
    Excel 2010 (2003 to 2016 but 2010 for choice)
    Posts
    1,766

    Is it possible to convert C++ code into VBA

    Is it possible to convert C++ code into VBA language? If yes then how do I do this?

    (I have no experience/knowledge of C++)
    *******************************************************

    HELP WANTED! (Links to Forum threads)
    Trying to create reusable code for Custom Events at Workbook (not Application) level

    *******************************************************

  2. #2
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,243

    Re: Is it possible to convert C++ code into VBA

    Hi

    http://www.tangiblesoftwaresolutions...r_Details.html

    I have no idea if this works..
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  3. #3
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,239

    Re: Is it possible to convert C++ code into VBA

    That's only for .net marvin. It depends on What the code does, you can do things in c++ that you can't in excel

  4. #4
    Valued Forum Contributor
    Join Date
    08-29-2012
    Location
    In lockdown
    MS-Off Ver
    Excel 2010 (2003 to 2016 but 2010 for choice)
    Posts
    1,766

    Re: Is it possible to convert C++ code into VBA

    Quote Originally Posted by Kyle123 View Post
    It depends on What the code does, you can do things in c++ that you can't in excel
    OK. Do you think it would be possible to convert the C++ code found here:

    http://msdn.microsoft.com/en-us/libr...(v=vs.85).aspx

    which I think is a function called from the C++ code here:

    http://msdn.microsoft.com/en-us/libr...(v=vs.85).aspx


    If it helps, I'm not seeking to convert all the code on these two pages. I'm only interested in the portion that will: "get the size by passing the first 24 bytes of the Header Object to the IMFASFContentInfo::GetHeaderSize method"

  5. #5
    Valued Forum Contributor
    Join Date
    08-29-2012
    Location
    In lockdown
    MS-Off Ver
    Excel 2010 (2003 to 2016 but 2010 for choice)
    Posts
    1,766

    Re: Is it possible to convert C++ code into VBA

    I'm trying to convert it but it is not easy (seeing as I have never learnt C++). What is this hr that appears a lot? Is hr the function result?

    Please Login or Register  to view this content.

  6. #6
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,972

    Re: Is it possible to convert C++ code into VBA

    It's an HRESULT which is a Long indicating the result of the function.
    Everyone who confuses correlation and causation ends up dead.

  7. #7
    Valued Forum Contributor
    Join Date
    08-29-2012
    Location
    In lockdown
    MS-Off Ver
    Excel 2010 (2003 to 2016 but 2010 for choice)
    Posts
    1,766

    Re: Is it possible to convert C++ code into VBA

    Quote Originally Posted by romperstomper View Post
    It's an HRESULT which is a Long indicating the result of the function.
    OK thanks.

    (Now I just have to figure out all the rest! )

  8. #8
    Valued Forum Contributor
    Join Date
    08-29-2012
    Location
    In lockdown
    MS-Off Ver
    Excel 2010 (2003 to 2016 but 2010 for choice)
    Posts
    1,766

    Re: Is it possible to convert C++ code into VBA

    what is DWORD? Is this a datatype? What is SUCCEEDED? It doesn't appear to be a function in the code so is it some C++ inbuilt function??


    Please Login or Register  to view this content.

  9. #9
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,972

    Re: Is it possible to convert C++ code into VBA

    This is a good list of types: http://codingdomain.com/visualbasic/win32api/datatypes/

    I don't think SUCCEEDED is built-in but it just tests if the value passed to it is >= 0.

  10. #10
    Valued Forum Contributor
    Join Date
    08-29-2012
    Location
    In lockdown
    MS-Off Ver
    Excel 2010 (2003 to 2016 but 2010 for choice)
    Posts
    1,766

    Re: Is it possible to convert C++ code into VBA

    Thanks again Rory

  11. #11
    Valued Forum Contributor
    Join Date
    08-29-2012
    Location
    In lockdown
    MS-Off Ver
    Excel 2010 (2003 to 2016 but 2010 for choice)
    Posts
    1,766

    Re: Is it possible to convert C++ code into VBA

    Well the code has less red text these days (see below) but I'm still in over my head.

    What is all the ->Lock ->Read etc?

    They seem to have some connection to the IMFMediaBuffer and IMFByteStream. I'm not sure what these are either. After googling I'm now thinking these could be APIs? Can anyone please confirm/deny?

    Please Login or Register  to view this content.

  12. #12
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,972

    Re: Is it possible to convert C++ code into VBA

    They are data types, not API functions.

  13. #13
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,644

    Re: Is it possible to convert C++ code into VBA

    You can't just ignore this part of the code, it's probably one of the most important parts of the code.
    Please Login or Register  to view this content.
    If posting code please use code tags, see here.

  14. #14
    Valued Forum Contributor
    Join Date
    08-29-2012
    Location
    In lockdown
    MS-Off Ver
    Excel 2010 (2003 to 2016 but 2010 for choice)
    Posts
    1,766

    Re: Is it possible to convert C++ code into VBA

    Quote Originally Posted by romperstomper View Post
    They are data types, not API functions.
    They are currently shown as data types in VBA because i made a guess at the time as to what they were. So you are saying my first guess was right?

    If they are data types then how can they can do things like
    Please Login or Register  to view this content.
    ?

    How do I recreate these in VBA or am I unable to because they are data types native to C++? (pls don't laugh, I have never used C or C++ languages)

  15. #15
    Valued Forum Contributor
    Join Date
    08-29-2012
    Location
    In lockdown
    MS-Off Ver
    Excel 2010 (2003 to 2016 but 2010 for choice)
    Posts
    1,766

    Re: Is it possible to convert C++ code into VBA

    Quote Originally Posted by Norie View Post
    You can't just ignore this part of the code, it's probably one of the most important parts of the code.
    Please Login or Register  to view this content.
    Thanks Norie. I'm guessing you can code in C++? What is the VBA equivalent of the .h lines? declarations of Class modules?

  16. #16
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,644
    They aren't declarations, they are compiler directives http://www.cplusplus.com/doc/tutorial/preprocessor/.
    Last edited by Norie; 05-23-2014 at 07:39 AM.

  17. #17
    Valued Forum Contributor
    Join Date
    08-29-2012
    Location
    In lockdown
    MS-Off Ver
    Excel 2010 (2003 to 2016 but 2010 for choice)
    Posts
    1,766

    Re: Is it possible to convert C++ code into VBA

    Quote Originally Posted by Norie View Post
    They aren't declarations, they are compiler directives http://www.cplusplus.com/doc/tutorial/preprocessor/.
    Thanks for pointing me to this. However as I have no knowledge of C++, I'm finding the tutorial confusing.

    Quote:
    Source file inclusion (#include)
    This directive has been used assiduously in other sections of this tutorial. When the preprocessor finds an #include directive it replaces it by the entire content of the specified header or file. There are two ways to use #include:

    12
    #include <header>
    #include "file"

    In the first case, a header is specified between angle-brackets <>. This is used to include headers provided by the implementation, such as the headers that compose the standard library (iostream, string,...). Whether the headers are actually files or exist in some other form is implementation-defined, but in any case they shall be properly included with this directive.
    What does it mean by 'headers'?

  18. #18
    Valued Forum Contributor
    Join Date
    08-29-2012
    Location
    In lockdown
    MS-Off Ver
    Excel 2010 (2003 to 2016 but 2010 for choice)
    Posts
    1,766

    Re: Is it possible to convert C++ code into VBA

    Unsolved. Closing thread because I only wanted to port C++ code to create one function in VBA.

    Which I have worked out myself.
    http://www.excelforum.com/excel-prog...structure.html

+ 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. How can i convert this to vba code
    By siobeh in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-04-2014, 09:20 PM
  2. [SOLVED] VBA code - Convert one value to another value
    By missy22 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-21-2012, 12:18 PM
  3. How To Convert VBA Code To DLL/XLL?
    By CaliKidd in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-17-2011, 11:19 AM
  4. VBA Code to Convert xls to pdf
    By LoveCandle in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-27-2009, 05:38 AM
  5. Convert VBA code to VB.NET
    By Sam Kelly. in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-18-2005, 05:45 AM

Tags for this Thread

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