ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Kind of embedded macro (https://www.excelbanter.com/excel-programming/337489-kind-embedded-macro.html)

Svedbo Active

Kind of embedded macro
 

I have detected a few functions in VBA that doesn't work properly whe
upgrading from 2000 to XP. So, I have this template with quite a fe
macros in it, which I have corrected to work properly in XP.

Now, I have used this template for quite some years and therefore hav
older excelsheets, that do not work now when I have upgraded to XP.

So instead of manually correct each file, I am thinking of writing som
kind of macro that automatically detects and changes the lines tha
needs to be corrected.

My question is therefo Is it possible to write a "macro tha
manipulates another macro"?

Or do I need to write that in another programming language?


Cheer

--
Svedbo Activ
-----------------------------------------------------------------------
Svedbo Active's Profile: http://www.excelforum.com/member.php...fo&userid=2636
View this thread: http://www.excelforum.com/showthread.php?threadid=39638


Norman Jones

Kind of embedded macro
 
Hi Svedbo Active,

I have detected a few functions in VBA that doesn't work properly when
upgrading from 2000 to XP.


I am aware of post-XL2K features which are not available in earlier
versions; I am not aware of the reverse. What are these functions?

My question is therefo Is it possible to write a "macro that
manipulates another macro"?

Or do I need to write that in another programming language?


See Chip Pearson's 'Programming to the VBE ' page at:

http://www.cpearson.com/excel/vbe.htm




Regards,
Norman



"Svedbo Active"
wrote in message
news:Svedbo.Active.1twiag_1124269536.6661@excelfor um-nospam.com...

I have detected a few functions in VBA that doesn't work properly when
upgrading from 2000 to XP. So, I have this template with quite a few
macros in it, which I have corrected to work properly in XP.

Now, I have used this template for quite some years and therefore have
older excelsheets, that do not work now when I have upgraded to XP.

So instead of manually correct each file, I am thinking of writing some
kind of macro that automatically detects and changes the lines that
needs to be corrected.

My question is therefo Is it possible to write a "macro that
manipulates another macro"?

Or do I need to write that in another programming language?


Cheers


--
Svedbo Active
------------------------------------------------------------------------
Svedbo Active's Profile:
http://www.excelforum.com/member.php...o&userid=26366
View this thread: http://www.excelforum.com/showthread...hreadid=396385




Svedbo Active[_2_]

Kind of embedded macro
 

Since my template's macro is corrected, and all I want to do is to ope
my earlier .xls-files and correct these macros, it might be easier t
just replace the VBA-projects that do not work, with the one tha
does?

But...how do i do this?

Basically, I have a lot of users that have used the template. So
would like to send them an email that says "In order for your exce
files created in excel 2000 to work in excel 2003, you need to run th
file correction.xls and follow the instructions"

Then, the correction.xls will contain a macro that prompts them t
browse to their file, kind of:

Sub UserChooseFile()
Dim f As Variant
Dim i As Integer
f = Application.GetOpenFilename()
If f < False Then
MsgBox "Open " & f
Workbooks.Open (f)
ThisWorkbook.Unprotect
Else
MsgBox "the Open was cancelled"
End If
'***** add process code here ******
End Sub

...found otherwhere on this forum.


When they then have opened their workbook, I need to replace the VB
project "connected" to their workbook, with the one that I hav
corrected.
(they are identical with the only exception that I have deleted
number of lines of code that do not work).

So, is it possible to replace one VBA project with another?


Would be grateful for any help

--
Svedbo Activ
-----------------------------------------------------------------------
Svedbo Active's Profile: http://www.excelforum.com/member.php...fo&userid=2636
View this thread: http://www.excelforum.com/showthread.php?threadid=39638


Svedbo Active[_3_]

Kind of embedded macro
 

Thanx Norman, I will have a look at Chip Person's page. Though, I'm no
that good at VB so I'm not sure I'll understand. Worth a try though.

Regarding the functions that don't work properly, you made me sweat
bit, 'cause it could well be that I'm wrong, but anyway:

If Worksheets("indata").Protect = True Then
Worksheets("indata").Unprotect
Else
End If

This code works in excel 2000, but not in excel 2003, as far as I coul
see.
It never detected that "indata" was protected and therefore didn'
unprotect it. This lead to the rest of the macro not working, wit
error messages like "Unable to set hidden property...etc"

What I did was then to simply just keep

Worksheets("indata").Unprotect

regardless of whether it already was unprotected or not.

But as I said, I might be wrong, but it sure as h*ll did not work unti
i changed it.
I also tried to add a watch to worksheets("indata"), (not sure abou
the result. Used to C++ but not to VBA)
and step through the code. The sheet was indeed protected, bu
ProtectionMode was false. ProtectContents was true though.

I dont know, but could this be the clue to the problem maybe?

Regard

--
Svedbo Activ
-----------------------------------------------------------------------
Svedbo Active's Profile: http://www.excelforum.com/member.php...fo&userid=2636
View this thread: http://www.excelforum.com/showthread.php?threadid=39638


Svedbo Active[_4_]

Kind of embedded macro
 

and as I expected, I didn't udnerstand Chris's site enough to solve m
problem.

So, if there is anyone out there that knows of code that copies th
total VBA project (objects, forms, modules) and replaces anothe
project with that one, please let me know

--
Svedbo Activ
-----------------------------------------------------------------------
Svedbo Active's Profile: http://www.excelforum.com/member.php...fo&userid=2636
View this thread: http://www.excelforum.com/showthread.php?threadid=39638



All times are GMT +1. The time now is 10:55 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com