From lbates@syscononline.com Fri Aug 2 19:42:01 2002 From: lbates@syscononline.com (Larry Bates) Date: Fri, 2 Aug 2002 13:42:01 -0500 Subject: [python-win32] OCX dilemma Message-ID: <2C1A673A677CD311988E00902773A6DD35C9BE@qbert.syscon-computers.com> I'm trying to use Expervision RTKocr toolkit for Optical Character Recognition of images. I have spent the last two days going through documentation, old questions posted to this and other lists, you name it. I'm attempting to get an OCX to work from within Python. So far I have accomplished the following: 1) The OCX is installed on my system and shows up in browser 2) I have run example program that came with toolkit that uses the OCX and it works perfectly. 3) I ran makepy and it generated a module that while cryptic, appears to work. At least I can import it without errors. 4) I can create instantiate a class using the class that was defined by makepy, but I can't seem to do anything with it. Example: I had makepy put it's output for the OCX into rtkocr.py from rtkocr import * r=Rtkocr() # This instantiates a class print r produces: This looks like its working to me. Then I get confused 'r' now has 5 methods/attributes CLSID, coclass_interfaces, coclass_sources, default_interface, default_source. The one that seems to look promising is default_interface. r.default_interface shows me the methods that I'm looking to be able to call. The first one I need to call is Init result=r.default_interface.Init(pBasePath,pTempPath,pCustID) gives the following: Traceback (most recent call last): File "", line 1, in ? TypeError: unbound method Init() must be called with instance as first argument Now I'm completely lost. HELP! Boy this COM/OCX stuff is REALLY confusing. Thanks in advance for any assistance. Regards, Larry Bates email: lbates@syscononline.com From Jim.Vickroy@noaa.gov Fri Aug 2 20:37:03 2002 From: Jim.Vickroy@noaa.gov (Jim Vickroy) Date: Fri, 02 Aug 2002 13:37:03 -0600 Subject: [python-win32] OCX dilemma References: <2C1A673A677CD311988E00902773A6DD35C9BE@qbert.syscon-computers.com> Message-ID: <3D4ADF5E.349BC684@noaa.gov> Hello Larry, I have no familiarity with this application, but in case no one more knowledgeable answers I can at least try to interpret the error message ... TypeError: unbound method Init() must be called with instance as first argument indicates, to me, that you must first construct/initialize an **instance** of the class whose Init() procedure you are trying to apply. For example: > my_instance = r.default_interface.<__init__procedure_name_goes_here()> > my_instance.Init(...) Hope this helps -- good luck. Larry Bates wrote: > I'm trying to use Expervision RTKocr toolkit for Optical > Character Recognition of images. > > I have spent the last two days going through documentation, > old questions posted to this and other lists, you name it. > I'm attempting to get an OCX to work from within Python. > So far I have accomplished the following: > > 1) The OCX is installed on my system and shows up in browser > 2) I have run example program that came with toolkit that uses > the OCX and it works perfectly. > 3) I ran makepy and it generated a module that while cryptic, > appears to work. At least I can import it without errors. > 4) I can create instantiate a class using the class that > was defined by makepy, but I can't seem to do anything > with it. > > Example: > > I had makepy put it's output for the OCX into rtkocr.py > > from rtkocr import * > r=Rtkocr() # This instantiates a class > print r > > produces: > > > > This looks like its working to me. > > Then I get confused > > 'r' now has 5 methods/attributes CLSID, coclass_interfaces, > coclass_sources, default_interface, default_source. > > The one that seems to look promising is default_interface. > > r.default_interface shows me the methods that I'm looking > to be able to call. The first one I need to call is Init > > result=r.default_interface.Init(pBasePath,pTempPath,pCustID) > > gives the following: > > Traceback (most recent call last): > File "", line 1, in ? > TypeError: unbound method Init() must be called with instance as first argument > > Now I'm completely lost. HELP! Boy this COM/OCX stuff is REALLY confusing. > > Thanks in advance for any assistance. > > Regards, > Larry Bates > email: lbates@syscononline.com > > _______________________________________________ > Python-win32 mailing list > Python-win32@python.org > http://mail.python.org/mailman/listinfo/python-win32 From mhammond@skippinet.com.au Sat Aug 3 17:24:37 2002 From: mhammond@skippinet.com.au (Mark Hammond) Date: Sun, 4 Aug 2002 02:24:37 +1000 Subject: [python-win32] OCX dilemma In-Reply-To: <2C1A673A677CD311988E00902773A6DD35C9BE@qbert.syscon-computers.com> Message-ID: > 1) The OCX is installed on my system and shows up in browser > 2) I have run example program that came with toolkit that uses > the OCX and it works perfectly. > 3) I ran makepy and it generated a module that while cryptic, > appears to work. At least I can import it without errors. > 4) I can create instantiate a class using the class that > was defined by makepy, but I can't seem to do anything > with it. > > Example: > > I had makepy put it's output for the OCX into rtkocr.py > > from rtkocr import * This isnt the preferred way of doing this. Generally you should just run makepy, and just use win32com.client.Dispatch() with the progID of the application. You will find this in any VB/JS samples. > r=Rtkocr() # This instantiates a class > print r You probably want to instantiate an 'interface'. The generated code may well have some comments of the form "this obhect can be created by prog ID xxx", and these are the objects you want to create, rather than the "coclass" classes. If you use the prog ID, it should just work. > r.default_interface shows me the methods that I'm looking > to be able to call. The first one I need to call is Init > > result=r.default_interface.Init(pBasePath,pTempPath,pCustID) Well, if you *really* want to continue down this route , default_interface is exactly the class you need. r.default_interface().Init(...) would work, but In the makepy file the Rtkocr class, another class will be named as the default_interface. This is the class name you could instantite instead of Rtkocr, and it should also work. Mark. From heo@propack-data.com Mon Aug 5 00:03:11 2002 From: heo@propack-data.com (heo@propack-data.com) Date: Mon, 5 Aug 2002 01:03:11 +0200 Subject: [python-win32] Heiko Ott/RaD/Propack Data GmbH is out of the office. Message-ID: I will be out of the office starting 07/26/2002 and will not return un= til 08/12/2002. I will respond to your message when I return. For PMX-related questions please contact Hans-Ulrich Seufert (email HUS@propack-data.com, phone +49 7564 93 24 0) at PD.BW. Best regards, Heiko Ott Research & Development -----------------------------------------------------------------------= ------------------------------ Propack Data GmbH Bauhofer Berg 7 88410 Bad Wurzach Germany phone +49 (7564) 9324-23 fax +49 (7564) 9324-11 e-mail heo@propack-data.com info http://www.propack-data.com = From lbates@syscononline.com Mon Aug 5 16:20:01 2002 From: lbates@syscononline.com (Larry Bates) Date: Mon, 5 Aug 2002 10:20:01 -0500 Subject: [python-win32] RE: OCX dilemma (round 2) In-Reply-To: <2C1A673A677CD311988E00902773A6DD5CBB3A@qbert.syscon-computers.com> Message-ID: <2C1A673A677CD311988E00902773A6DD35C9CE@qbert.syscon-computers.com> Mark, If I EVER get this working I'm going to write a tutorial and post it somewhere. Thanks for the additional information. I was apparently trying to make it harder than it is. I knew that there was some significance to the line I saw in the generated makepy file that read: # This CoClass is known by the name 'RTKOCR.RtkocrCtrl.1' was meaningful but for the life of me I couldn't figure out what to do with it. Follow-up question: The following program now aborts with an Unexpected failure error. import win32com from win32com import client RtkocrCtrl=win32com.client.Dispatch("RTKOCR.RtkocrCtrl.1") BaseDir="C:\\Program Files\\ExperVision\\OpenRTK 6.1" TempDir="C:\\temp" CustomerID="600-RTK-6395803603" # # Call Init method of the OCX # sErrorNo=RtkocrCtrl.Init(BaseDir,TempDir,CustomerID) Traceback (most recent call last): File "", line 1, in ? File "c:\python21\win32com\gen_py\AA6B2720-ACDE-11CF-8BB0-0080C80C4FAEx0x1x0.py", line 41, in DispError return self._oleobj_.InvokeTypes(0x8, LCID, 1, (24, 0), ((2, 0),),usErrorNo) com_error: (-2147418113, 'Unexpected failure', None, None) I've triple checked the Init variables, looked at the VB example (see below) and I just don't see what I'm doing incorrectly. Any thoughts? VB Example: Private Sub InitBtn_Click() Dim sErrorNo As Long Dim BaseDir As String BaseDir = BaseDirText.Text Dim TempDir As String TempDir = BaseDirText.Text ShowMessage ("Initializing...") sErrorNo = RtkocrCtrl.Init(BaseDir, TempDir, CustomerID) If sErrorNo <> 0 Then RtkocrCtrl.DispError (sErrorNo) Else ShowMessage ("Init Success!") End If End Sub Thanks, Larry Bates -----Original Message----- From: python-win32-admin@python.org [mailto:python-win32-admin@python.org]On Behalf Of python-win32-request@python.org Sent: Sunday, August 04, 2002 11:00 AM To: python-win32@python.org Subject: Python-win32 digest, Vol 1 #182 - 1 msg Send Python-win32 mailing list submissions to python-win32@python.org To subscribe or unsubscribe via the World Wide Web, visit http://mail.python.org/mailman/listinfo/python-win32 or, via email, send a message with subject or body 'help' to python-win32-request@python.org You can reach the person managing the list at python-win32-admin@python.org When replying, please edit your Subject line so it is more specific than "Re: Contents of Python-win32 digest..." Today's Topics: 1. RE: OCX dilemma (Mark Hammond) --__--__-- Message: 1 From: "Mark Hammond" To: , Subject: RE: [python-win32] OCX dilemma Date: Sun, 4 Aug 2002 02:24:37 +1000 > 1) The OCX is installed on my system and shows up in browser > 2) I have run example program that came with toolkit that uses > the OCX and it works perfectly. > 3) I ran makepy and it generated a module that while cryptic, > appears to work. At least I can import it without errors. > 4) I can create instantiate a class using the class that > was defined by makepy, but I can't seem to do anything > with it. > > Example: > > I had makepy put it's output for the OCX into rtkocr.py > > from rtkocr import * This isnt the preferred way of doing this. Generally you should just run makepy, and just use win32com.client.Dispatch() with the progID of the application. You will find this in any VB/JS samples. > r=Rtkocr() # This instantiates a class > print r You probably want to instantiate an 'interface'. The generated code may well have some comments of the form "this obhect can be created by prog ID xxx", and these are the objects you want to create, rather than the "coclass" classes. If you use the prog ID, it should just work. > r.default_interface shows me the methods that I'm looking > to be able to call. The first one I need to call is Init > > result=r.default_interface.Init(pBasePath,pTempPath,pCustID) Well, if you *really* want to continue down this route , default_interface is exactly the class you need. r.default_interface().Init(...) would work, but In the makepy file the Rtkocr class, another class will be named as the default_interface. This is the class name you could instantite instead of Rtkocr, and it should also work. Mark. --__--__-- _______________________________________________ Python-win32 mailing list Python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32 End of Python-win32 Digest From arosado@softhome.net Wed Aug 7 01:44:33 2002 From: arosado@softhome.net (Andres Rosado) Date: Tue, 06 Aug 2002 20:44:33 -0400 Subject: [python-win32] Passing parameters to a Win32 app Message-ID: <5.1.0.14.0.20020806204409.00bd43d8@mail.softhome.net> I'm making a signature program in Python. If I run the email client doesn't need parameters, it works OK. But if I pass any parameters, it "discards" them. Originally, the script used os.spawnl() to execute the app. Then I installed the Win32 extensions and neither win32api.ShellExecute(), nor win32api.WinExec(), nor win32process.CreateProcess() have given me any good results. I also searched on Google Groups and found a solution using os.spawnv(). I tried it and it doesn't work. Is there something I'm overlooking? Which should function should I use? Thanks for your help! ----------------------------------- Andres Rosado Email: andresr@despammed.com ICQ: 66750646 Homepage: http://andres980.tripod.com/ He who laughs, lasts. From jens.jorgensen@tallan.com Wed Aug 7 15:15:45 2002 From: jens.jorgensen@tallan.com (Jens B. Jorgensen) Date: Wed, 07 Aug 2002 09:15:45 -0500 Subject: [python-win32] Passing parameters to a Win32 app References: <5.1.0.14.0.20020806204409.00bd43d8@mail.softhome.net> Message-ID: <3D512B91.2060708@tallan.com> You could include some more information here. It's hard to tell what the problem may be without further information on how you're passing the parameters/creating the command line. Did you try the os.system() function? Andres Rosado wrote: > I'm making a signature program in Python. If I run the email client > doesn't need parameters, it works OK. But if I pass any parameters, it > "discards" them. Originally, the script used os.spawnl() to execute > the app. Then I installed the Win32 extensions and neither > win32api.ShellExecute(), nor win32api.WinExec(), nor > win32process.CreateProcess() have given me any good results. > > I also searched on Google Groups and found a solution using > os.spawnv(). I tried it and it doesn't work. > > Is there something I'm overlooking? Which should function should I use? > > Thanks for your help! > > > ----------------------------------- > Andres Rosado > Email: andresr@despammed.com > ICQ: 66750646 > Homepage: http://andres980.tripod.com/ > > He who laughs, lasts. > > > _______________________________________________ > Python-win32 mailing list > Python-win32@python.org > http://mail.python.org/mailman/listinfo/python-win32 -- Jens B. Jorgensen jens.jorgensen@tallan.com "With a focused commitment to our clients and our people, we deliver value through customized technology solutions" From Jim Abrams Wed Aug 7 15:49:13 2002 From: Jim Abrams (Jim Abrams) Date: Wed, 7 Aug 2002 10:49:13 -0400 Subject: [python-win32] Install win32all-147.exe over ActiveState? Message-ID: <345405362.20020807104913@publishingresources.com> Can I install win32all-147.exe directly over the ActiveState disto 2.1.1 without any problems to get the ASP performance and bug fixes? --- Jim Abrams Sr. Software Engineer Publishing Resources, Inc. 732.548.4609x22 jabrams@publishingresources.com Public Key Available: Send me mail: mailto:jabrams@publishingresources.com?subject=PUBKEY From b.hall@irl.cri.nz Thu Aug 8 03:40:03 2002 From: b.hall@irl.cri.nz (Blair Hall) Date: Thu, 08 Aug 2002 14:40:03 +1200 Subject: [python-win32] Stopping a program in PythonWin? Message-ID: <5.1.0.14.1.20020808141029.00a20130@pop.wgtn.irl.cri.nz> Could anyone tell me please how to break out of execution when running something in the PythonWin environment. For example, suppose I had defined a long loop like def boring(): for i in range(10000): print 'bored' and then in the interactive window typed >>> boring() How could I avoid waiting for the loop to run its course? Ctrl-C does not seem to work, nor anything else on my keyboard (except Ctrl-Alt-Delete, which is rather too drastic) From mhammond@skippinet.com.au Thu Aug 8 05:19:42 2002 From: mhammond@skippinet.com.au (Mark Hammond) Date: Thu, 8 Aug 2002 14:19:42 +1000 Subject: [python-win32] Install win32all-147.exe over ActiveState? In-Reply-To: <345405362.20020807104913@publishingresources.com> Message-ID: I'm not sure :) I have heard a rumour that it works OK, but I have never tested it. Officially, you should unintall APy and reinstall Python + win32all. Mark. > -----Original Message----- > From: python-win32-admin@python.org > [mailto:python-win32-admin@python.org]On Behalf Of Jim Abrams > Sent: Thursday, 8 August 2002 12:49 AM > To: Python Win32 > Subject: [python-win32] Install win32all-147.exe over ActiveState? > > > > Can I install win32all-147.exe directly over the ActiveState disto > 2.1.1 without any problems to get the ASP performance and bug fixes? > > --- > Jim Abrams > Sr. Software Engineer > Publishing Resources, Inc. > 732.548.4609x22 > jabrams@publishingresources.com > > Public Key Available: Send me mail: > mailto:jabrams@publishingresources.com?subject=PUBKEY > > > _______________________________________________ > Python-win32 mailing list > Python-win32@python.org > http://mail.python.org/mailman/listinfo/python-win32 From marka@sundance.com Thu Aug 8 12:33:14 2002 From: marka@sundance.com (Mark Ainsworth) Date: Thu, 8 Aug 2002 12:33:14 +0100 Subject: [python-win32] Getting ASP to reload Message-ID: <000001c23ecf$62da47e0$0a00a8c0@Exodus> Sorry if this has been asked before. I am using Python as my ASP script host. Everything appears to work ok but… I am using a simple routine to load data from an odbc source (MS access mdb file). Everything displays ok. Parameters are passed to the page as to what data to display using ?name=data pairs. However, if I press the refresh button (IE 5.5) the page appears to hang and not display any data. If I then write the asp source file from my editor and then press the refresh button it works again. It won't appear to refresh properly until it finds that the source has been changed. It must be something really stupid, but what have I got set up wrong. Thanks in anticipation. Mark Ainsworth Quality Manager Sundance Multiprocessor Technology Ltd. Chiltern House, Waterside, Chesham, Bucks HP5 1PS Tel. +44 1494 793167 Fax. +44 1494 793168 MarkA@sundance.com http://www.sundance.com From rogermallett@hotmail.com Thu Aug 8 16:30:15 2002 From: rogermallett@hotmail.com (Roger Mallett) Date: Thu, 08 Aug 2002 15:30:15 +0000 Subject: [python-win32] Stopping a program in PythonWin? Message-ID: >Ctrl-C does not seem to work Explicitly kill the Process _________________________________________________________________ Join the world’s largest e-mail service with MSN Hotmail. http://www.hotmail.com From mhammond@skippinet.com.au Fri Aug 9 05:20:35 2002 From: mhammond@skippinet.com.au (Mark Hammond) Date: Fri, 9 Aug 2002 14:20:35 +1000 Subject: FW: [python-win32] Stopping a program in PythonWin? Message-ID: <009b01c23f5c$1c0b5100$0100a8c0@eden> Oops - forgot to CC the list -----Original Message----- From: Mark Hammond [mailto:mhammond@skippinet.com.au] Sent: Thursday, 8 August 2002 2:20 PM To: Blair Hall Subject: RE: [python-win32] Stopping a program in PythonWin? Right-click on the Pythonwin icon in the taskbar, and select "Break into running code" MArk. > -----Original Message----- > From: python-win32-admin@python.org > [mailto:python-win32-admin@python.org]On Behalf Of Blair Hall > Sent: Thursday, 8 August 2002 12:40 PM > To: python-win32@python.org > Subject: [python-win32] Stopping a program in PythonWin? > > > Could anyone tell me please how to break out of execution when > running something in the PythonWin environment. > > For example, suppose I had defined a long loop like > > def boring(): > for i in range(10000): > print 'bored' > > and then in the interactive window typed > > >>> boring() > > How could I avoid waiting for the loop to run its course? > Ctrl-C does not seem to work, nor anything else > on my keyboard (except Ctrl-Alt-Delete, which is rather too drastic) > > > _______________________________________________ > Python-win32 mailing list > Python-win32@python.org > http://mail.python.org/mailman/listinfo/python-win32 From mhammond@skippinet.com.au Fri Aug 9 05:20:35 2002 From: mhammond@skippinet.com.au (Mark Hammond) Date: Fri, 9 Aug 2002 14:20:35 +1000 Subject: [python-win32] Getting ASP to reload In-Reply-To: <000001c23ecf$62da47e0$0a00a8c0@Exodus> Message-ID: This was a bug, and has been fixed in win32all 147/148. Mark. > -----Original Message----- > From: python-win32-admin@python.org > [mailto:python-win32-admin@python.org]On Behalf Of Mark Ainsworth > Sent: Thursday, 8 August 2002 9:33 PM > To: python-win32@python.org > Subject: [python-win32] Getting ASP to reload > > > Sorry if this has been asked before. > > I am using Python as my ASP script host. Everything appears to > work ok but… > > I am using a simple routine to load data from an odbc source (MS > access mdb > file). Everything displays ok. Parameters are passed to the page > as to what > data to display using ?name=data pairs. However, if I press the refresh > button (IE 5.5) the page appears to hang and not display any > data. If I then > write the asp source file from my editor and then press the refresh button > it works again. It won't appear to refresh properly until it > finds that the > source has been changed. > > It must be something really stupid, but what have I got set up wrong. > > Thanks in anticipation. > > Mark Ainsworth > Quality Manager > Sundance Multiprocessor Technology Ltd. > Chiltern House, Waterside, Chesham, Bucks HP5 1PS > Tel. +44 1494 793167 Fax. +44 1494 793168 > MarkA@sundance.com http://www.sundance.com > > > > _______________________________________________ > Python-win32 mailing list > Python-win32@python.org > http://mail.python.org/mailman/listinfo/python-win32 > From jcoruna@ibdosnorte.com Mon Aug 12 18:57:35 2002 From: jcoruna@ibdosnorte.com (=?iso-8859-1?Q?Juan_Carlos_CORU=D1A?=) Date: Mon, 12 Aug 2002 19:57:35 +0200 Subject: [python-win32] Returning IDispatch from a COM server method Message-ID: <000001c24229$be1a6b50$c002633e@jcoruna> Hi all! I'm trying to develop two COM servers in python and a method of one of them must return a instance of the other COM server. The method is: interface IBusAdapter : IDispatch { .... [id(1005), helpstring("method CreateoutMessage")] HRESULT CreateoutMessage([out, retval] IDispatch **pIOutMessage); .... }; This is the OutMessage COM object: interface IOutMessage : IDispatch { .... [id(1001), helpstring("method Send")] HRESULT Send([in]long TimeOut, [out,retval] VARIANT_BOOL *Sent); .... }; The two objects are coded in the same python module: class BusAdapter: .... def CreateoutMessage(self, group): """method CreateoutMessage""" om =3D OutMessage() return win32com.server.util.wrap(om) class OutMessage: .... def Send(self, TimeOut): .... As you can see I have tried wrapping the OutMessage instance without success. Can anyone explain me the way to return a COM server within the method of another COM server? Thanks. Juan Carlos Coru=F1a jcoruna@ibdosnorte.com From b.hall@irl.cri.nz Wed Aug 14 00:34:49 2002 From: b.hall@irl.cri.nz (Blair Hall) Date: Wed, 14 Aug 2002 11:34:49 +1200 Subject: [python-win32] Grabbing an active Excel application Message-ID: <5.1.0.14.1.20020814113045.00a35070@pop.wgtn.irl.cri.nz> I have a Python routine that will start Excel, write stuff to it, close it, etc. Now someone wants to use it, but they wish to open Excel themselves!!! How would I use Python to 'connect' to an already open Excel application? Are there any issues / gotchas with actually doing this? From jh@magnus.dk Wed Aug 14 13:10:45 2002 From: jh@magnus.dk (Jesper Hertel) Date: Wed, 14 Aug 2002 14:10:45 +0200 Subject: [python-win32] Re: Problems using JET SQL CREATE TABLE statem ent Message-ID: Hi George, any news on this subject? I have a similar problem, although not from within Python, but from Visual Basic 6. I'd like to hear of any solutions. Best regards, Jesper Hertel Software Developer Magnus Informatik A/S (a Wolters Kluwer company) Denmark jh@magnus.dk -----Original Message----- From: Kunkle, Rob E [mailto:REKd@pge.com] Sent: Friday, July 19, 2002 12:48 AM To: python-win32@python.org Cc: George Vestergom Subject: RE: [python-win32] Re: Problems using JET SQL CREATE TABLE statem ent Hi George - I know the Access tables have a property that says whether or not they are Visible in the database window. Maybe ADO does not do this by default? I can't find the details of this, but it could be that you just need to somehow manipulate the extended properties of the table object and flip a switch. Probably ADOX is your best bet to get more control of the objects. Rob -----Original Message----- From: Jorgensen, Jens [mailto:jjorgensen@Tallan.com] Sent: Wednesday, July 17, 2002 1:43 PM To: George Vestergom; python-win32@python.org Subject: RE: [python-win32] Re: Problems using JET SQL CREATE TABLE statement George, Although I can't be certain I'm going to guess that the differences in behavior between Python and VBS are occuring because when you are executing the statements in Python the objects do not get deleted and somehow the data is not being written through to the file. Some of the scenarios support this and others contradict it but I still believe this is the case. Since the interface is COM the COM objects themselves don't know if python is calling them or VBS is and the results should be no different. Try putting your statements into a .py file and running the scripts with python.exe rathen than pythonwin. Any difference observed then? BTW I use ADO myself and manipulate Jet databases fairly often and at times use Access in tandem and haven't seen any problems like this. You can create new Jet databases too, you just use ADOX. ADOX also let's you get lists of tables, etc. -----Original Message----- From: George Vestergom [mailto:unifoam@total.net] Sent: Wed 7/17/2002 10:22 AM To: 'python-win32@python.org' Cc: Subject: [python-win32] Re: Problems using JET SQL CREATE TABLE statement 2002 July 17, Wednesday Problem: When trying to use the CREATE TABLE statement (JET SQL), the table is created but does not show up in the Database Window in ACCESS. Enumerating the TableDefs collection in Python shows that the table has been added, but doesn't show up when I run ACCESS. Refreshing the window doesn't do anything. When the same statement is performed in a VBA Module, the table is created and shows up in the Database Window. Assumptions: 1. ACCESS 2000 / DAO 3.6 2. Python 2.2 3. win32all-148 4. MakePy on DAO 3.6 Object Library Example Session using Pythonwin (just to illustrate what I've done >>> # open a database and print out objects. >>> # database contains 2 tables >>> from win32com.client import Dispatch, constants >>> dbe = Dispatch('DAO.DBEngine.36') >>> wrk = dbe.Workspaces(0) >>> db = wrk.OpenDatabase('pydb.mdb') >>> dbe >>> wrk >>> db >>> # enumerate TableDefs (system tables not shown) will print 2 tables currently in the database: >>> tbldefs = db.TableDefs >>> for tbl in tbldefs: print tbl.Name tblEx01 tblEx02 >>> # now lets create a new table using JET SQL >>> txtsql = 'CREATE TABLE tblNewTable (Name CHAR(40), City CHAR(40) );' >>> db.Execute(txtsql) Everything's okay here, table is created, no problem. Now let's refresh TableDefs and print it out. >>> db.TableDefs.Refresh() >>> tbldefs = db.TableDefs >>> for tbl in tbldefs: print i.Name tblEx01 tblEx02 tblNewTable If I switch to ACCESS and refresh the Database Window, table tblNewTable is not included in the list. I've tried the following scenarios: 1. If I close both ACCESS and Pythonwin and re-open the file with ACCESS, the new table tblNewTable is not shown. 2. Closing ACCESS and running Pythonwin: table shows up in the TableDefs collection! 3. Closing Pythonwin and opening ACCESS: If I use the CREATE TABLE (from above) in a Sub procedure, using the SAME name, the table is created AND SHOWS UP IN THE DATABASE WINDOW! One would think an error would have been raised at this point. 4. Closing ACCESS and opening Pythonwin: I can add new records to this table using the following JET SQL INSERT statement: >>> r = 'INSERT INTO tblNewTable (Name, City) VALUES ("George", "Toronto");' >>> db.Execute(r) and will show up in Python. No data is shown in ACCESS, even if the table was first created using VBA in a module. It may not be too important of a problem since I haven't had any problem (so far) using DOA in Python. I just wanted to find out if JET SQL works the same way and apparently I've come across these "warts". Any ideas? George Vestergom _______________________________________________ Python-win32 mailing list Python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32 ?+a|"}j)b b') Úœmà ¶+az+᥃Ybà ²~ hᢟ _______________________________________________ Python-win32 mailing list Python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32 From jens.jorgensen@tallan.com Wed Aug 14 15:38:02 2002 From: jens.jorgensen@tallan.com (Jens B. Jorgensen) Date: Wed, 14 Aug 2002 09:38:02 -0500 Subject: [python-win32] Grabbing an active Excel application References: <5.1.0.14.1.20020814113045.00a35070@pop.wgtn.irl.cri.nz> Message-ID: <3D5A6B4A.3000105@tallan.com> This is a cryptographically signed message in MIME format. --------------ms010702030006070400030307 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit In fact if you create 'excel.application' it will "attach" to the already running version. In fact I frequently use it in this fashion. I typically do: from win32com.client import Dispatch xl = Dispatch('excel.application') sht = xl.ActiveSheet sht.Cells(1, 1).Value= "foo" Blair Hall wrote: > I have a Python routine that will start Excel, write stuff to it, > close it, etc. > > Now someone wants to use it, but they wish to open Excel themselves!!! > > How would I use Python to 'connect' to an already open Excel application? > Are there any issues / gotchas with actually doing this? > > > _______________________________________________ > Python-win32 mailing list > Python-win32@python.org > http://mail.python.org/mailman/listinfo/python-win32 -- Jens B. Jorgensen jens.jorgensen@tallan.com "With a focused commitment to our clients and our people, we deliver value through customized technology solutions" --------------ms010702030006070400030307 Content-Type: application/x-pkcs7-signature; name="smime.p7s" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="smime.p7s" Content-Description: S/MIME Cryptographic Signature MIAGCSqGSIb3DQEHAqCAMIACAQExCzAJBgUrDgMCGgUAMIAGCSqGSIb3DQEHAQAAoIIJmjCC AyswggKUoAMCAQICAwdmRzANBgkqhkiG9w0BAQQFADCBkjELMAkGA1UEBhMCWkExFTATBgNV BAgTDFdlc3Rlcm4gQ2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Hxa+BB4ByfdUq2SWLcgrZxHIIGTqdSFnHJAAAAAAAA --------------ms010702030006070400030307-- From David Rock Thu Aug 15 20:59:22 2002 From: David Rock (David Rock) Date: Thu, 15 Aug 2002 14:59:22 -0500 Subject: [python-win32] Using win32net functions Message-ID: <20020815145922.A13375@wdfs.graniteweb.com> I am trying to use win32net.NetUserEnum and am confused about what parameters it is looking for. Does anyone have a clear example of how to use it? Thanks. -- David Rock david@rock.homelinux.com From wolf@circle-cross.org Thu Aug 15 22:31:38 2002 From: wolf@circle-cross.org (Wolf Logan) Date: Thu, 15 Aug 2002 14:31:38 -0700 Subject: [python-win32] drag-and-drop with python WSH scripts Message-ID: <019e01c244a3$23b49370$2001020a@circlecross.home> This is a multi-part message in MIME format. ------=_NextPart_000_019B_01C24468.7738BD90 Content-Type: text/plain; charset="Windows-1252" Content-Transfer-Encoding: quoted-printable i want to be able to drag-and-drop items onto .pys scripts the same way = you can with .vbs scripts (as described in = http://msdn.microsoft.com/library/default.asp?url=3D/library/en-us/script= 56/html/wsdraganddrop.asp). i believe this is similar to what ian = bicking was looking to do in = http://mail.python.org/pipermail/python-win32/2002-April/000323.html=20 after facing a couple hours of frustration and not finding any useful = pointers on the net, i started poking through the registry. i discovered = that the reason i couldn't drop items onto .pys files was that there's a = registry key missing (apparently one of the keys that should be created = by the process that registers the python scripting engine with WSH). the = key should be: HKEY_CLASSES_ROOT\pysFile\ShellEx\DropHandler and should contain the (Default) string value, set to = "{60254CA5-953B-11CF-8C96-00AA00B8708C}". this registers the script = files as "drop targets", with the WSH shell helper handling the = dropping. dropped items appear in the script as WScript.Arguments, the = same as they do in any other WSH script. hope this helps someone else do something useful. ------=_NextPart_000_019B_01C24468.7738BD90 Content-Type: text/html; charset="Windows-1252" Content-Transfer-Encoding: quoted-printable
i want to be able to drag-and-drop items onto .pys = scripts the=20 same way you can with .vbs scripts (as described in http://msdn.microsoft.com/library/default.asp?url=3D/library/en-= us/script56/html/wsdraganddrop.asp). i believe this is similar to what ian bicking was looking to = do in http://mail.python.org/pipermail/python-win32/2002-April/000323.html=  
 
after facing a couple hours of frustration and not = finding any=20 useful pointers on the net, i started poking through the registry. i = discovered=20 that the reason i couldn't drop items onto .pys files was that there's a = registry key missing (apparently one of the keys that should be created = by the=20 process that registers the python scripting engine with WSH). the key = should=20 be:
 
HKEY_CLASSES_ROOT\pysFile\ShellEx\DropHandler
 
and should contain the (Default) string value, set = to=20 "{60254CA5-953B-11CF-8C96-00AA00B8708C}". this registers the script = files as=20 "drop targets", with the WSH shell helper handling the dropping. dropped = items=20 appear in the script as WScript.Arguments, the same as they do in any = other WSH=20 script.
 
hope this helps someone else do something=20 useful.
------=_NextPart_000_019B_01C24468.7738BD90-- From b.hall@irl.cri.nz Thu Aug 15 04:53:45 2002 From: b.hall@irl.cri.nz (Blair Hall) Date: Thu, 15 Aug 2002 15:53:45 +1200 Subject: [python-win32] Grabbing an active Excel application Message-ID: <5.1.0.14.1.20020815153326.00a1f190@pop.wgtn.irl.cri.nz> Further to my posting yesterday, and Jens' suggestion, I find that 'grabbing' an existing Excel is still problematic. Here is __init__ from my class that wants to use Excel def __init__(self , visible=1 ): """ Create a new file in the current working directory and save a new Excel workbook in it. """ try: self.__app = win32com.client.Dispatch("Excel.Application") self.__app.Visible = visible except pythoncom.com_error, e: self.__comExceptionHandler(e) When I instantiate that class the first time, then all is fine. ie: >>> xl = myClass() However, if I then immediately do something silly like >>> xl = myClass() Excel disappears from view (it is still running though). From that point on Python and Excel don't seem to be quite able to agree on how to interact. It seems that Jens' suggestion is fine, but in case I am looking for a few more idiot-proof safeguards. By the way, I am working on Win95. From David.Cantrell@Gunter.AF.mil Wed Aug 14 18:37:22 2002 From: David.Cantrell@Gunter.AF.mil (David.Cantrell@Gunter.AF.mil) Date: Wed, 14 Aug 2002 12:37:22 -0500 Subject: [python-win32] regular expressions question Message-ID: <092C0521BB49C34AB7DF7578B6D513E014A12F@fsjubj09> Hi all, Do you know a way to wrap regular expressions around newlines, but STOP when a certain pattern is reached? In other words, given the following source: Some leading text here. Block 1 Symbol: text here Symbol: text here Symbol: text here Other stuff here End Block Block 2 Symbol: text here Symbol: text here Symbol: text here Other stuff here End Block Some trailing text here. (I'm parsing VBScript files and extracting method comments, but the above is simpler to deal with) I have a regexp that retrieves a list of all Blocks, so given the above the list looks like: methodlist = [ "Block 1", "Block 2" ] If I use re.DOTALL: for item in methodlist: print item, "\n-----\n" print re.search( item + ".*End Block", s, re.DOTALL ).group() print "\n" I get the following (of course): Block 1 ----- Block 1 Symbol: text here Symbol: text here Symbol: text here Other stuff here End Block Block 2 Symbol: text here Symbol: text here Symbol: text here Other stuff here End Block Block 2 ----- Block 2 Symbol: text here Symbol: text here Symbol: text here Other stuff here End Block But I eventually want to build a list that looks like this: [ ( "Block 1", "Symbol: text here\nSymbol: text here\nSymbol: text here" ) ( "Block 2", "Symbol: text here\nSymbol: text here\nSymbol: text here" ) ] In order to do that, I need to know how to make the regexp engine STOP once it gets past the last "Symbol: " line after each Block declaration. (I know the regexp I gave goes from Block..End Block, but that's only because I don't know how to "get all Symbol lines that come immediately after a Block declaration") Any help is much appreciated!! :D Thanks, -dave From b.hall@irl.cri.nz Fri Aug 16 05:08:25 2002 From: b.hall@irl.cri.nz (Blair Hall) Date: Fri, 16 Aug 2002 16:08:25 +1200 Subject: [python-win32] Starting COM questions Message-ID: <5.1.0.14.1.20020816155846.00a37dd0@pop.wgtn.irl.cri.nz> I need to develop some COM stuff later in the year (my first attempt at COM programming) and I am asking myself whether to do it with Python or VisualC++6. I have two questions: 1) I have found John Nielsen's "Python, C++ and COM" and would like to gather up more documentation like this that could ease my passage (eg HowTos, examples, tutorials, ...). I have not found much else so far. 2) Perhaps more important, supposing I do develop my COM components with Python. They only need to be prototypes, so optimisation is not an issue. However, the possibility of distributing them to others (for evaluation) is. Given that the potential evaluation platforms won't have Python, how useful are my components going to be? To put it another way, can anyone comment on how one distributes Python COM components? From jens.jorgensen@tallan.com Fri Aug 16 17:40:49 2002 From: jens.jorgensen@tallan.com (Jens B. Jorgensen) Date: Fri, 16 Aug 2002 11:40:49 -0500 Subject: [python-win32] Grabbing an active Excel application References: <5.1.0.14.1.20020815153326.00a1f190@pop.wgtn.irl.cri.nz> Message-ID: <3D5D2B11.5070106@tallan.com> It gets worse. I find that if I have a python open that has a reference to an Excel.Application object and then I close the Excel window while python is still running then if I later run Excel the inner frame of the window gets hung (never paints, shows image of what was behind the window). I'm sure this is not a python problem per se but a COM one. In this case I can look at the process manager and find a running excel.exe. I have to kill that process and then start again to get back to normal. Blair Hall wrote: > Further to my posting yesterday, and Jens' suggestion, I find that > 'grabbing' > an existing Excel is still problematic. > > Here is __init__ from my class that wants to use Excel > > def __init__(self > , visible=1 > ): > """ > Create a new file in the current working directory > and save a new Excel workbook in it. > """ > try: > self.__app = win32com.client.Dispatch("Excel.Application") > self.__app.Visible = visible > except pythoncom.com_error, e: > self.__comExceptionHandler(e) > > When I instantiate that class the first time, then all > is fine. ie: > > >>> xl = myClass() > > However, if I then immediately do something silly like > > >>> xl = myClass() > > Excel disappears from view (it is still running though). From that point > on Python and Excel don't seem to be quite able to agree on how > to interact. > > It seems that Jens' suggestion is fine, but in case I am looking for > a few more idiot-proof safeguards. > > By the way, I am working on Win95. > > > > _______________________________________________ > Python-win32 mailing list > Python-win32@python.org > http://mail.python.org/mailman/listinfo/python-win32 -- Jens B. Jorgensen jens.jorgensen@tallan.com "With a focused commitment to our clients and our people, we deliver value through customized technology solutions" From b.hall@irl.cri.nz Fri Aug 16 22:00:17 2002 From: b.hall@irl.cri.nz (Blair Hall) Date: Sat, 17 Aug 2002 09:00:17 +1200 Subject: [python-win32] Grabbing an active Excel application In-Reply-To: <3D5D2B11.5070106@tallan.com> References: <5.1.0.14.1.20020815153326.00a1f190@pop.wgtn.irl.cri.nz> Message-ID: <5.1.0.14.1.20020817085722.00a23760@pop.wgtn.irl.cri.nz> Exactly! I would like to try and design the Python application to handle COM better. However, I need some advice on how to do that. At 11:40 16/08/02 -0500, Jens B. Jorgensen wrote: >It gets worse. I find that if I have a python open that has a reference to >an Excel.Application object and then I close the Excel window while python >is still running then if I later run Excel the inner frame of the window >gets hung (never paints, shows image of what was behind the window). I'm >sure this is not a python problem per se but a COM one. In this case I can >look at the process manager and find a running excel.exe. I have to kill >that process and then start again to get back to normal. > >Blair Hall wrote: > >>Further to my posting yesterday, and Jens' suggestion, I find that 'grabbing' >>an existing Excel is still problematic. >> >>Here is __init__ from my class that wants to use Excel >> >> def __init__(self >> , visible=1 >> ): >> """ >> Create a new file in the current working directory >> and save a new Excel workbook in it. >> """ >> try: >> self.__app = win32com.client.Dispatch("Excel.Application") >> self.__app.Visible = visible >> except pythoncom.com_error, e: >> self.__comExceptionHandler(e) >> >>When I instantiate that class the first time, then all >>is fine. ie: >> >> >>> xl = myClass() >> >>However, if I then immediately do something silly like >> >> >>> xl = myClass() >> >>Excel disappears from view (it is still running though). From that point >>on Python and Excel don't seem to be quite able to agree on how >>to interact. >> >>It seems that Jens' suggestion is fine, but in case I am looking for >>a few more idiot-proof safeguards. >> >>By the way, I am working on Win95. >> >> >> >>_______________________________________________ >>Python-win32 mailing list >>Python-win32@python.org >>http://mail.python.org/mailman/listinfo/python-win32 > > >-- >Jens B. Jorgensen >jens.jorgensen@tallan.com > >"With a focused commitment to our clients and our people, we deliver value >through customized technology solutions" > > From jens.jorgensen@tallan.com Sat Aug 17 06:04:43 2002 From: jens.jorgensen@tallan.com (Jens B. Jorgensen) Date: Sat, 17 Aug 2002 00:04:43 -0500 Subject: [python-win32] Grabbing an active Excel application References: <5.1.0.14.1.20020815153326.00a1f190@pop.wgtn.irl.cri.nz> <5.1.0.14.1.20020817085722.00a23760@pop.wgtn.irl.cri.nz> Message-ID: <3D5DD96B.6080703@tallan.com> This is a cryptographically signed message in MIME format. --------------ms050003090509040709030608 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Yeah, it's really probably a design insufficiency in OLE. There may be a workaround but it would require an understanding of OLE that I don't have. Blair Hall wrote: > Exactly! > I would like to try and design the Python application to handle COM > better. > However, I need some advice on how to do that. > > At 11:40 16/08/02 -0500, Jens B. Jorgensen wrote: > >> It gets worse. I find that if I have a python open that has a >> reference to an Excel.Application object and then I close the Excel >> window while python is still running then if I later run Excel the >> inner frame of the window gets hung (never paints, shows image of >> what was behind the window). I'm sure this is not a python problem >> per se but a COM one. In this case I can look at the process manager >> and find a running excel.exe. I have to kill that process and then >> start again to get back to normal. >> >> Blair Hall wrote: >> >>> Further to my posting yesterday, and Jens' suggestion, I find that >>> 'grabbing' >>> an existing Excel is still problematic. >>> >>> Here is __init__ from my class that wants to use Excel >>> >>> def __init__(self >>> , visible=1 >>> ): >>> """ >>> Create a new file in the current working directory >>> and save a new Excel workbook in it. >>> """ >>> try: >>> self.__app = win32com.client.Dispatch("Excel.Application") >>> self.__app.Visible = visible >>> except pythoncom.com_error, e: >>> self.__comExceptionHandler(e) >>> >>> When I instantiate that class the first time, then all >>> is fine. ie: >>> >>> >>> xl = myClass() >>> >>> However, if I then immediately do something silly like >>> >>> >>> xl = myClass() >>> >>> Excel disappears from view (it is still running though). From that >>> point >>> on Python and Excel don't seem to be quite able to agree on how >>> to interact. >>> >>> It seems that Jens' suggestion is fine, but in case I am looking for >>> a few more idiot-proof safeguards. >>> >>> By the way, I am working on Win95. >>> >>> >>> >>> _______________________________________________ >>> Python-win32 mailing list >>> Python-win32@python.org >>> http://mail.python.org/mailman/listinfo/python-win32 >> >> >> >> -- >> Jens B. Jorgensen >> jens.jorgensen@tallan.com >> >> "With a focused commitment to our clients and our people, we deliver >> value through customized technology solutions" >> >> > > > _______________________________________________ > Python-win32 mailing list > Python-win32@python.org > http://mail.python.org/mailman/listinfo/python-win32 -- Jens B. Jorgensen jens.jorgensen@tallan.com "With a focused commitment to our clients and our people, we deliver value through customized technology solutions" --------------ms050003090509040709030608 Content-Type: application/x-pkcs7-signature; name="smime.p7s" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="smime.p7s" Content-Description: S/M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4V79OLLqDKpRrt3tM+DY8St 27yUnp+0VJeFpOiPQVSvEOMiY9xdDucPlp3g3LeGwBxcqJts6mI+6YyFakEdF3uFDTe6rTov D4FC0mHvHv67swIERh+Ei81n3RHhZiwUIu6NGhFNAIf2XupVcrs9eRHz0m4VR2UcfdGwINha icRpKO5cSAKEw8ZvzAOJlvwchMHETehDk2ceAAAAAAAA --------------ms050003090509040709030608-- From niki@vintech.bg Mon Aug 19 08:31:42 2002 From: niki@vintech.bg (Niki Spahiev) Date: Mon, 19 Aug 2002 10:31:42 +0300 Subject: [python-win32] Starting COM questions References: <5.1.0.14.1.20020816155846.00a37dd0@pop.wgtn.irl.cri.nz> Message-ID: <3D609EDE.6020400@vintech.bg> Blair Hall wrote: > I need to develop some COM stuff later in the year (my first > attempt at COM programming) and I am asking myself whether > to do it with Python or VisualC++6. > > I have two questions: > > 1) I have found John Nielsen's "Python, C++ and COM" and would like to > gather up more documentation like this that could ease my passage > (eg HowTos, examples, tutorials, ...). I have not found much else so far. > > 2) Perhaps more important, supposing I do develop my COM components > with Python. They only need to be prototypes, so optimisation is not an > issue. > However, the possibility of distributing them to others (for evaluation) > is. > > Given that the potential evaluation platforms won't have Python, how useful > are my components going to be? > > To put it another way, can anyone comment on how one distributes Python COM > components? We (Vintech Ltd.) develop and distribute Python COM components using Python Installer and small patch to support regsvr32. Patch is available in Installer mail archive. Problem is that one can't test Python COM server with Python COM client (at least not same python version). HTH Niki Spahiev From miracle@paradise.net.nz Thu Aug 22 01:04:02 2002 From: miracle@paradise.net.nz (Matthew Sherborne) Date: Thu, 22 Aug 2002 12:04:02 +1200 Subject: [python-win32] Python COM server publishing events Message-ID: <3D642A72.90309@paradise.net.nz> How can I publish events in a python COM server? please... eg. http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cossdk/htm/pgservices_events_5sok.asp Thanks Matthew Sherborne From heo@propack-data.com Fri Aug 23 11:32:14 2002 From: heo@propack-data.com (heo@propack-data.com) Date: Fri, 23 Aug 2002 12:32:14 +0200 Subject: [python-win32] missing OleLoadPicturePath, LoadPicture for usage with MS imagelist control... Message-ID: Hi! I'm using the MS treeview control und want to assign different images f= or every node type. Normally this is no problem - using the imagelist cont= rol is an easy task. My problem: The images in the imagelist control are located on disk and I'm unable = to add them since I do not know how to create a IPicture object. In VB or = COM SDK I have helper functions like LoadPicture or OleLoadPicture for such= a task - is there a way to this directly with the COM extensions or do I = have to write my own extension... Thanks for your hints! Heiko heo@propack-data.com = From mhammond@skippinet.com.au Sat Aug 24 07:38:55 2002 From: mhammond@skippinet.com.au (Mark Hammond) Date: Sat, 24 Aug 2002 16:38:55 +1000 Subject: [python-win32] missing OleLoadPicturePath, LoadPicture for usage with MS imagelist control... In-Reply-To: Message-ID: The best thing would be to add OleLoadLPicture to pythoncom.cpp, so that all future users also have access to it. I am able to guide you through this. Mark. > -----Original Message----- > From: python-win32-admin@python.org > [mailto:python-win32-admin@python.org]On Behalf Of heo@propack-data.com > Sent: Friday, 23 August 2002 8:32 PM > To: python-win32@python.org > Subject: [python-win32] missing OleLoadPicturePath, LoadPicture for > usage with MS imagelist control... > > > Hi! > > I'm using the MS treeview control und want to assign different images for > every node type. Normally this is no problem - using the imagelist control > is an easy task. > > My problem: > The images in the imagelist control are located on disk and I'm unable to > add them since I do not know how to create a IPicture object. In VB or COM > SDK I have helper functions like LoadPicture or OleLoadPicture for such a > task - is there a way to this directly with the COM extensions or > do I have > to write my own extension... > > Thanks for your hints! > > Heiko > heo@propack-data.com > > > > _______________________________________________ > Python-win32 mailing list > Python-win32@python.org > http://mail.python.org/mailman/listinfo/python-win32 > From MarkA@sundance.com Thu Aug 29 12:01:34 2002 From: MarkA@sundance.com (Mark Ainsworth) Date: Thu, 29 Aug 2002 12:01:34 +0100 Subject: [python-win32] fiddling with results from an ADODB access. Message-ID: Sorry if this is a dumb question, but I can't seem to find the answer anywhere. I have a simple asp page displaying the contents of a remote dbase. It works ok but... The values returned for the date field are formatted using US layout ie.d mm/dd/yy I want to change them to UK values dd/mm/yy. However all the conversion routines I have tried don't want to work. The values returned aren't date/time, even thought that is the allocation in the dbase. They aren't simple strings either. Yet I can write them to the HTML page without problems. The timespent value is stored as an integer, but again it won't behave as an integer. If I try converting it using int() it comes back with an error message saying it isn't a string, but it is a Unicode. But the Unicode decoding routines won't work either. So the simple question is: How can I perform simple conversion on returned values so I can actually do things with them? I need to convert to date/time and integer values. Thank you for your patience. TotalTime = 0 while not objRS.EOF: Response.Write('') Response.Write(objRS("Project")) Response.Write('') Response.Write(objRS("LogDate")) Response.Write('') stTime = "%s" % objRS("TimeSpent").Value # doesn't matter if I use .value or not. # stTime still doesn't behave like a string so # I can convert it latter. Bert = int(stTime) Response.Write(stTime) Response.Write("") objRS.Move(1) objRS.Close() Error Type: Python ActiveX Scripting Engine (0x80020009) Traceback (most recent call last): File "