Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default 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" wrote in message
...
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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default 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
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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default 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
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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default 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
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
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
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Getting the Date Format Being Used By The Operating System And Exc Sunnous Excel Programming 1 November 17th 05 12:33 PM
Find out Operating System Mohan[_2_] Excel Programming 5 January 16th 04 08:36 PM
mail program & operating system steve Excel Programming 2 September 23rd 03 10:26 PM
Operating system Don Guillett[_4_] Excel Programming 0 September 10th 03 04:43 PM
Operating system Stephan Kassanke Excel Programming 0 September 10th 03 04:42 PM


All times are GMT +1. The time now is 11:31 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"