Distinguish between Windows Xp and Windows Vista

A

ARbitOUR

Damn!!!! This forum has been SOOO helpful in the past...I'll be sure to
donate to this site when I make it big..LOL

Anyways, I desperately need code that will determine the operating
system that is used by the end-user. I don't need the version number
returned as a value but purely an indication of which operating system
is in use - especially whether it is Windows XP or Windows Vista (the
service pack is irrelevant).

For interests' sake, the reason I need to distinguish between the two /
various operating systems is that I use SendKeys to navigate the menus
of MS Paint and the menu layouts of MS Paint for XP is not exactly the
same as that of MS Paint shipped with Vista. Obviously I will be using
IF statements to indicate the procedure to follow dependant on the
Operating system in use... Any help? Anyone? ? THX IN ADVANCE!
 
P

Peter T

ARbitOUR said:
Thx for the reply Peter!
:)

Regarding Sendkeys: If it doesn't work in Vista, why does it work on my
copy of Vista?

Just wondering....


How curious, SendKeys now seems to be working in my Vista too. It definitely
didn't work before in uncompiled VBA as a Standard User, though it did work
in compiled VB6 (but not in the IDE) and IIRC also with VBA with the UAC off
as administrator.

I can only assume some recent Vista update is why it now appears to work.
However best not assume it will work for all, a quick search will give you
hundreds of pages on the topic, with complaints about SendKeys not working
in Vista and loads of API driven alternative solutions.

Regards,
Peter T
 
S

Simon Lloyd

There were many fixes in the latest updates of Vista, and sendkeys was
probably included, just like Excel 2007 doesn't support FileSearch there
is said:
How curious, SendKeys now seems to be working in my Vista too. It
definitely
didn't work before in uncompiled VBA as a Standard User, though it did
work
in compiled VB6 (but not in the IDE) and IIRC also with VBA with the
UAC off
as administrator.

I can only assume some recent Vista update is why it now appears to
work.
However best not assume it will work for all, a quick search will give
you
hundreds of pages on the topic, with complaints about SendKeys not
working
in Vista and loads of API driven alternative solutions.

Regards,
Peter T


--
Simon Lloyd

Regards,
Simon Lloyd
'Microsoft Office Help' (http://www.thecodecage.com)
 
A

ARbitOUR

How curious, SendKeys now seems to be working in my Vista too. I
definitely
didn't work before in uncompiled VBA as a Standard User, though it di
work
in compiled VB6 (but not in the IDE) and IIRC also with VBA with th
UAC off
as administrator.

I can only assume some recent Vista update is why it now appears t
work.
However best not assume it will work for all, a quick search will giv
you
hundreds of pages on the topic, with complaints about SendKeys no
working
in Vista and loads of API driven alternative solutions.

Regards,
Peter T

True, sendkeys does have it's fair share of problems. However whethe
it works or not for the end user doesn't matter that much to me. I onl
used sendkeys in a value added macro for the end user that runs a
'e-mail prep' routine copying ranges to MS paint ans saves it as a bm
with pre-defined file name for ease of location -> it's simply a smal
part of the whole workbook. Initialy my main concern with send keys wa
primarily the numlock handling that varied between XP and Vista (i.e
checking the state of numlock before running the process, then togglin
it back to it's original state after the process is complete.

Furtunately not many of the end-users will be running it on Vista (m
PC at work runs XP and so does most of the other end-user's PC's).

Either way, thx for the feedback Peter

:
 
P

Peter T

just like Excel 2007 doesn't support FileSearch there
is soon to be a fix in the latest service pack to bring that back

Really? Could you point to the source where that is confirmed, thanks.

Regards,
Peter T
 
P

Peter T

Not sure I quite follow but if the objective is to save a copy of part of a
worksheet as a BMP neither SendKeys nor use of a third party app such as
MSPaint are required.

Regards,
Peter T
 
A

ARbitOUR

Peter said:
Not sure I quite follow but if the objective is to save a copy of par
of a
worksheet as a BMP neither SendKeys nor use of a third party app suc
as
MSPaint are required.

Regards,
Peter T

If you imply copying the required range to a chart / graph the
exporting it as an image file...I've already tried that and yes it doe
work...

...However, unfortunately there tends to be some colour degradatio
when the resulting image is printed (so much so that certain text
values on the quotation becomes illegible...not only when printing, bu
also on the digital file itself).

So the chart/graph method doesn't help me much.

If there is a third way, I'd love to know how...

:
 
P

Peter T

I think I know why your chart Export is not coming out clear for you but can
be made fine. But there's a better way -

Get hold of Stephen Bullen's PastePicture.zip (from memory in downloads or
excel files)
http://www.oaltd.co.uk

Drag the module modPastePicture into your project. This provides the APIs
and wrapper functions required to get the image off the clipboard and save
to file. Adapt something like the following to your needs -

Sub TestRangeToBMP()
Dim lPicType As Long
Dim vFile As Variant
Dim oPic As IPictureDisp

lPicType = xlBitmap ' xlPicture for metafile or *.emf

vFile = Application.DefaultFilePath & "\TestRangeToBMP.bmp"
' or say
' vFile = Application.GetSaveAsFilename(etc

Range("a1:k20").Copy

Set oPic = PastePicture(lPicType)

SavePicture oPic, vFile
Application.CutCopyMode = False

End Sub


Normally you would want to use the CopyPicture function to give the choice
of working with a BMP or a metafile (emf). However CopyPicture is buggy in
Excel2007 unless you know exactly what you are doing (ie which formats work
with which object types - don't rely on Help or intellisense which are
wrong). The simple Copy function puts both bmp & metafile image formats on
the clipboard from range, shape and chartarea objects in 2007 (but in
earlier versions, if shape object only a metafile).

Finally, if you are concerned with quality you may find the metafile works
much better for you. Depends on what you want to do, in particular it scales
much better. Also smaller file size.

Regards,
Peter T
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top