Results 1 to 6 of 6

Thread: adapt vb code to be used with microsoft excel vba

  1. #1

    Thread Starter
    New Member
    Join Date
    Dec 2017
    Posts
    3

    adapt vb code to be used with microsoft excel vba

    adapt vb code to be used with microsoft excel vba

    Good evening.

    I seem to have understood that it is possible to use the vb code also for excel macros.

    I found this link on the web that allows with vb to send sms using the nokia gsm phone:

    http://www.scampers.org/steve/sms/samples.htm#at


    It is possible to know if the code can be inserted in an excel macro module and if it is possible what adaptations need to be made.

    Thanks

  2. #2
    Addicted Member habenero's Avatar
    Join Date
    Aug 2015
    Posts
    217

    Re: adapt vb code to be used with microsoft excel vba

    Hello

    I do this almost every week - the joining of VBA and VB6

    But the best way to start is to use the macro recorder in excel (or whatever) and then Frankenstein the code using VB6. Also with research on the net

    Hope I kind of helped

    Jeff

  3. #3

    Thread Starter
    New Member
    Join Date
    Dec 2017
    Posts
    3

    Re: adapt vb code to be used with microsoft excel vba

    Quote Originally Posted by habenero View Post
    Hello

    I do this almost every week - the joining of VBA and VB6

    But the best way to start is to use the macro recorder in excel (or whatever) and then Frankenstein the code using VB6. Also with research on the net

    Hope I kind of helped

    Jeff
    I would like to know if the same code can be inserted in an excel module or if it needs to be adapted

  4. #4
    Addicted Member habenero's Avatar
    Join Date
    Aug 2015
    Posts
    217

    Re: adapt vb code to be used with microsoft excel vba

    ok - will look into it

    can you post some VBA and then I can see if I can help

    Jeff

  5. #5

    Thread Starter
    New Member
    Join Date
    Dec 2017
    Posts
    3

    Re: adapt vb code to be used with microsoft excel vba

    Quote Originally Posted by habenero View Post
    ok - will look into it

    can you post some VBA and then I can see if I can help

    Jeff
    Is the opposite.
    I would like to make the vb code of the posted link suitable for use as an excel vba macro.
    Could you help me with this?

  6. #6
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,455

    Re: adapt vb code to be used with microsoft excel vba

    you can use a lot of vba code in vb6, you should avoid using active anything, selecting or selection object. all ranges should be fully qualified to a application.workbook.worksheet object
    like
    Code:
    set sht = xlapp.workbooks("myworkbook").sheets("sheet1")
    sht.range("a1").value = 275454
    where xlapp is an excel application object, the sht object can then be used for all ranges and other objects within that worksheet, while it remains in scope, any unqualified objects may work sometimes and then not

    well written vba code will mostly just work, but often vba code needs upgrading to work reliably

    you can use early binding or late binding to an excel object, the latter is excel version independent, whereas the former will only work with that specific version of excel
    i do not believe that any 64 bit calls from vba can be implemented in vb6, but most code will still run in 64 bit versions of excel, though as i do not have any 64 bit version i can not test

    edit: i doubt there is any serious problem converting the SDK code from the link to vba, just need to download and add a reference to NokiaCLMessaging, but it is not included in the sample programs as far as i could see
    Last edited by westconn1; Jan 15th, 2021 at 03:06 AM.
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

Posting Permissions

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



Click Here to Expand Forum to Full Width