+ Reply to Thread
Results 1 to 6 of 6

Run certain macros based on operating system

  1. #1
    Mr. Smith
    Guest

    Run certain macros based on operating system

    I need a workbook with macros that need to run on machines
    with older versions of Windows NT 4 and others on Windows XP
    Professional.
    Instead of making two separate workbooks, I'd like an IF-THEN
    scenario using the =INFO("osversion") formula to determine the
    operating system and if it's not XP -- I get "Windows (32-bit) NT
    5.01" with the osversion formula on the XP machines -- to run the
    NT-compatible macro.
    But, being a newbie, I don't know how to go about that.
    I Googled for an example, but came up empty. I would have to
    imagine someone else has come across this problem before.
    Thanks for any help/pointers, etc.

  2. #2
    Dave Peterson
    Guest

    Re: Run certain macros based on operating system

    if lcase(Application.OperatingSystem) = lcase("Windows (32-bit) NT 5.01") then
    'do xp stuff
    else
    'do non-xp stuff
    end if

    Just curious -- what will you be using that depends on the operating system
    version?

    "Mr. Smith" wrote:
    >
    > I need a workbook with macros that need to run on machines
    > with older versions of Windows NT 4 and others on Windows XP
    > Professional.
    > Instead of making two separate workbooks, I'd like an IF-THEN
    > scenario using the =INFO("osversion") formula to determine the
    > operating system and if it's not XP -- I get "Windows (32-bit) NT
    > 5.01" with the osversion formula on the XP machines -- to run the
    > NT-compatible macro.
    > But, being a newbie, I don't know how to go about that.
    > I Googled for an example, but came up empty. I would have to
    > imagine someone else has come across this problem before.
    > Thanks for any help/pointers, etc.


    --

    Dave Peterson

  3. #3
    NickHK
    Guest

    Re: Run certain macros based on operating system

    I was going to say Conditional compilation,
    e.g. < In a module >
    Public Enum OSVersion
    OS_Unknown = 0
    OS_NT = 4
    OS_2K = 5
    OS_XP = 6
    End Enum

    #Const OS =5
    </ In a module >

    <Wherever you need to check the OS version>
    #If OS = OS_NT Then
    'NT code
    #ElseIf OS = OS_2K Then
    MsgBox "W2K code only"
    'XP code
    #ElseIf OS = OS_XP Then
    'XP code
    #Else
    'Exit/warning
    #End If
    </Wherever you need to check the OS version>

    But...
    Seems that these constants cannot be not Public, so you will have to add a
    "#Const OS =5" to each module that will use it.
    Also, these constant do not seem to like comparison to an enum, so you have
    to the numeric values.

    So you will have to change the value of "OS" on each of the modules,
    depending on the platform that it is destined for.

    But as dave enquired, is this really necessary ?

    NickHK

    "Mr. Smith" <[email protected]> wrote in message
    news:[email protected]...
    > I need a workbook with macros that need to run on machines
    > with older versions of Windows NT 4 and others on Windows XP
    > Professional.
    > Instead of making two separate workbooks, I'd like an IF-THEN
    > scenario using the =INFO("osversion") formula to determine the
    > operating system and if it's not XP -- I get "Windows (32-bit) NT
    > 5.01" with the osversion formula on the XP machines -- to run the
    > NT-compatible macro.
    > But, being a newbie, I don't know how to go about that.
    > I Googled for an example, but came up empty. I would have to
    > imagine someone else has come across this problem before.
    > Thanks for any help/pointers, etc.




  4. #4
    Mr. Smith
    Guest

    Re: Run certain macros based on operating system

    Dave:
    Thanks. I'll give it a whirl.
    One other question: Is there a way for the macro to just look
    at "Windows (32-bit) NT 5" and "Windows (32-bit) NT 4" portion to
    determine if it's an XP or NT machine? (I want to be sure it will run
    whether it's 5.01 or 5.02, etc.)
    Where I work, we have a mix of NT4 machines that should be in
    a Dumpster and XP Pro workstations. Because people jump around, they'd
    need this workbook to work wherever they are.
    Specifically, the workbook with the macros does its thing then
    e-mails the resulting workbook. With XP, I have a macro that calls the
    mail server (bypassing the need for an e-mail client) and will
    silently send the workbook. This is the way I'd prefer, but on NT, it
    doesn't work. I have another macro that does, which uses Outlook to
    mail the file. The macro that works on NT, doesn't work on XP, and
    vice versa.
    I'm sure there are easier ways to do this stuff but I'm not
    savvy with Excel.
    Thanks again for the help.


    On Thu, 27 Jul 2006 16:27:37 -0500, Dave Peterson
    <[email protected]> wrote:

    >if lcase(Application.OperatingSystem) = lcase("Windows (32-bit) NT 5.01") then
    > 'do xp stuff
    >else
    > 'do non-xp stuff
    >end if
    >
    >Just curious -- what will you be using that depends on the operating system
    >version?
    >
    >"Mr. Smith" wrote:
    >>
    >> I need a workbook with macros that need to run on machines
    >> with older versions of Windows NT 4 and others on Windows XP
    >> Professional.
    >> Instead of making two separate workbooks, I'd like an IF-THEN
    >> scenario using the =INFO("osversion") formula to determine the
    >> operating system and if it's not XP -- I get "Windows (32-bit) NT
    >> 5.01" with the osversion formula on the XP machines -- to run the
    >> NT-compatible macro.
    >> But, being a newbie, I don't know how to go about that.
    >> I Googled for an example, but came up empty. I would have to
    >> imagine someone else has come across this problem before.
    >> Thanks for any help/pointers, etc.



  5. #5
    Dave Peterson
    Guest

    Re: Run certain macros based on operating system

    Couldn't you just look at the first xx characters:

    if lcase(left(application.operatingsystem,19)) _
    = lcase("Windows (32-bit) NT") then

    or

    if lcase(application.operatingsystem) like lcase("Windows (32-bit) NT*") then
    ....

    ===========
    Ron de Bruin has a bunch of notes about emailing via code:
    http://www.rondebruin.nl/sendmail.htm

    I think he uses CDO (I've never used it) to overcome some problems with
    different versions of Outlook.

    "Mr. Smith" wrote:
    >
    > Dave:
    > Thanks. I'll give it a whirl.
    > One other question: Is there a way for the macro to just look
    > at "Windows (32-bit) NT 5" and "Windows (32-bit) NT 4" portion to
    > determine if it's an XP or NT machine? (I want to be sure it will run
    > whether it's 5.01 or 5.02, etc.)
    > Where I work, we have a mix of NT4 machines that should be in
    > a Dumpster and XP Pro workstations. Because people jump around, they'd
    > need this workbook to work wherever they are.
    > Specifically, the workbook with the macros does its thing then
    > e-mails the resulting workbook. With XP, I have a macro that calls the
    > mail server (bypassing the need for an e-mail client) and will
    > silently send the workbook. This is the way I'd prefer, but on NT, it
    > doesn't work. I have another macro that does, which uses Outlook to
    > mail the file. The macro that works on NT, doesn't work on XP, and
    > vice versa.
    > I'm sure there are easier ways to do this stuff but I'm not
    > savvy with Excel.
    > Thanks again for the help.
    >
    > On Thu, 27 Jul 2006 16:27:37 -0500, Dave Peterson
    > <[email protected]> wrote:
    >
    > >if lcase(Application.OperatingSystem) = lcase("Windows (32-bit) NT 5.01") then
    > > 'do xp stuff
    > >else
    > > 'do non-xp stuff
    > >end if
    > >
    > >Just curious -- what will you be using that depends on the operating system
    > >version?
    > >
    > >"Mr. Smith" wrote:
    > >>
    > >> I need a workbook with macros that need to run on machines
    > >> with older versions of Windows NT 4 and others on Windows XP
    > >> Professional.
    > >> Instead of making two separate workbooks, I'd like an IF-THEN
    > >> scenario using the =INFO("osversion") formula to determine the
    > >> operating system and if it's not XP -- I get "Windows (32-bit) NT
    > >> 5.01" with the osversion formula on the XP machines -- to run the
    > >> NT-compatible macro.
    > >> But, being a newbie, I don't know how to go about that.
    > >> I Googled for an example, but came up empty. I would have to
    > >> imagine someone else has come across this problem before.
    > >> Thanks for any help/pointers, etc.


    --

    Dave Peterson

  6. #6
    Mr. Smith
    Guest

    Re: Run certain macros based on operating system

    Dave:
    I believe I got the code to e-mail without a client from Ron's
    site. My preference is to do it without a client, which may come back
    to bite me.
    Thanks again for your help.



    On Fri, 28 Jul 2006 13:56:01 -0500, Dave Peterson
    <[email protected]> wrote:

    >Couldn't you just look at the first xx characters:
    >
    >if lcase(left(application.operatingsystem,19)) _
    > = lcase("Windows (32-bit) NT") then
    >
    >or
    >
    >if lcase(application.operatingsystem) like lcase("Windows (32-bit) NT*") then
    >...
    >
    >===========
    >Ron de Bruin has a bunch of notes about emailing via code:
    >http://www.rondebruin.nl/sendmail.htm
    >
    >I think he uses CDO (I've never used it) to overcome some problems with
    >different versions of Outlook.
    >
    >"Mr. Smith" wrote:
    >>
    >> Dave:
    >> Thanks. I'll give it a whirl.
    >> One other question: Is there a way for the macro to just look
    >> at "Windows (32-bit) NT 5" and "Windows (32-bit) NT 4" portion to
    >> determine if it's an XP or NT machine? (I want to be sure it will run
    >> whether it's 5.01 or 5.02, etc.)
    >> Where I work, we have a mix of NT4 machines that should be in
    >> a Dumpster and XP Pro workstations. Because people jump around, they'd
    >> need this workbook to work wherever they are.
    >> Specifically, the workbook with the macros does its thing then
    >> e-mails the resulting workbook. With XP, I have a macro that calls the
    >> mail server (bypassing the need for an e-mail client) and will
    >> silently send the workbook. This is the way I'd prefer, but on NT, it
    >> doesn't work. I have another macro that does, which uses Outlook to
    >> mail the file. The macro that works on NT, doesn't work on XP, and
    >> vice versa.
    >> I'm sure there are easier ways to do this stuff but I'm not
    >> savvy with Excel.
    >> Thanks again for the help.
    >>
    >> On Thu, 27 Jul 2006 16:27:37 -0500, Dave Peterson
    >> <[email protected]> wrote:
    >>
    >> >if lcase(Application.OperatingSystem) = lcase("Windows (32-bit) NT 5.01") then
    >> > 'do xp stuff
    >> >else
    >> > 'do non-xp stuff
    >> >end if
    >> >
    >> >Just curious -- what will you be using that depends on the operating system
    >> >version?
    >> >
    >> >"Mr. Smith" wrote:
    >> >>
    >> >> I need a workbook with macros that need to run on machines
    >> >> with older versions of Windows NT 4 and others on Windows XP
    >> >> Professional.
    >> >> Instead of making two separate workbooks, I'd like an IF-THEN
    >> >> scenario using the =INFO("osversion") formula to determine the
    >> >> operating system and if it's not XP -- I get "Windows (32-bit) NT
    >> >> 5.01" with the osversion formula on the XP machines -- to run the
    >> >> NT-compatible macro.
    >> >> But, being a newbie, I don't know how to go about that.
    >> >> I Googled for an example, but came up empty. I would have to
    >> >> imagine someone else has come across this problem before.
    >> >> Thanks for any help/pointers, etc.



+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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