Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 194
Default HELP! Macros point to wrong file!

I launched Excel and got a blank workbook. Actually, it was my
Personal.xls, but it was blank. So I typed in it and SavedAs a new name.
Now all my macros want the file I SavedAs, not Personal.xls!! I can
right-click on my toolbars to get Customize, then right-click on a macro
button to see the Assign(ed) Macro, and it's pointing to this other file. I
deleted it, and restarted, but it didn't help. All the modules are still in
Personal. How do I change back 34 modules?

Ed


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default HELP! Macros point to wrong file!

Loop through your commandbars and the controls on the commandbars, test the
onaction property to see if it contains a reference to the new file and if
so, change it back by modifying the string (onaction property value) and
assigning it back to the onaction property.

sPath = "C:\Program Files\Microsoft Office\Office\xlStart\Personal.xls"

'start of loop

if obj.onaction < "" then
if instr(1,.obj.onaction,"C:\My folder\myfile.xls",vbTextCompare) then
obj.onaction = Application.Substitute(obj.Onaction,"C:\My
Folder\myfile.xls",sPath)
end if
end if

next obj

where obj is a reference to your commandbar button.

--
Regards,
Tom Ogilvy

"Ed" wrote in message
...
I launched Excel and got a blank workbook. Actually, it was my
Personal.xls, but it was blank. So I typed in it and SavedAs a new name.
Now all my macros want the file I SavedAs, not Personal.xls!! I can
right-click on my toolbars to get Customize, then right-click on a macro
button to see the Assign(ed) Macro, and it's pointing to this other file.

I
deleted it, and restarted, but it didn't help. All the modules are still

in
Personal. How do I change back 34 modules?

Ed




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 194
Default HELP! Macros point to wrong file!

Tom, thanks for the help. I am having some problems, though.

How do I set a reference to all my CommandBar Buttons?
Isn't "Next" the end of a loop? What starts the loop? What did I miss?

Ed

"Tom Ogilvy" wrote in message
...
Loop through your commandbars and the controls on the commandbars, test

the
onaction property to see if it contains a reference to the new file and if
so, change it back by modifying the string (onaction property value) and
assigning it back to the onaction property.

sPath = "C:\Program Files\Microsoft Office\Office\xlStart\Personal.xls"

'start of loop

if obj.onaction < "" then
if instr(1,.obj.onaction,"C:\My folder\myfile.xls",vbTextCompare) then
obj.onaction = Application.Substitute(obj.Onaction,"C:\My
Folder\myfile.xls",sPath)
end if
end if

next obj

where obj is a reference to your commandbar button.

--
Regards,
Tom Ogilvy

"Ed" wrote in message
...
I launched Excel and got a blank workbook. Actually, it was my
Personal.xls, but it was blank. So I typed in it and SavedAs a new

name.
Now all my macros want the file I SavedAs, not Personal.xls!! I can
right-click on my toolbars to get Customize, then right-click on a macro
button to see the Assign(ed) Macro, and it's pointing to this other

file.
I
deleted it, and restarted, but it didn't help. All the modules are

still
in
Personal. How do I change back 34 modules?

Ed






  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default HELP! Macros point to wrong file!

See where it says "start of loop". This is called pseudo code.

I don't know where your references are. Are they all on one commandbar.
Do you need to recursively search every button in Excel?

--
Regards,
Tom Ogilvy

"Ed" wrote in message
...
Tom, thanks for the help. I am having some problems, though.

How do I set a reference to all my CommandBar Buttons?
Isn't "Next" the end of a loop? What starts the loop? What did I miss?

Ed

"Tom Ogilvy" wrote in message
...
Loop through your commandbars and the controls on the commandbars, test

the
onaction property to see if it contains a reference to the new file and

if
so, change it back by modifying the string (onaction property value) and
assigning it back to the onaction property.

sPath = "C:\Program Files\Microsoft Office\Office\xlStart\Personal.xls"

'start of loop

if obj.onaction < "" then
if instr(1,.obj.onaction,"C:\My folder\myfile.xls",vbTextCompare) then
obj.onaction = Application.Substitute(obj.Onaction,"C:\My
Folder\myfile.xls",sPath)
end if
end if

next obj

where obj is a reference to your commandbar button.

--
Regards,
Tom Ogilvy

"Ed" wrote in message
...
I launched Excel and got a blank workbook. Actually, it was my
Personal.xls, but it was blank. So I typed in it and SavedAs a new

name.
Now all my macros want the file I SavedAs, not Personal.xls!! I can
right-click on my toolbars to get Customize, then right-click on a

macro
button to see the Assign(ed) Macro, and it's pointing to this other

file.
I
deleted it, and restarted, but it didn't help. All the modules are

still
in
Personal. How do I change back 34 modules?

Ed








  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 194
Default HELP! Macros point to wrong file!

Tom, thanks for trying. During the interim, I manually changed the
pointers. I didn't even know, though, what I was looking at to change until
I read through your code.

I think I really need to get some VBA training, or at east a VBA-specific
book. "Next" and where my buttons are shouldn't be hard to know, and
shouldn't require a personal expert to hold my hand. I sincerely appreciate
your help.

Ed

"Tom Ogilvy" wrote in message
...
See where it says "start of loop". This is called pseudo code.

I don't know where your references are. Are they all on one commandbar.
Do you need to recursively search every button in Excel?

--
Regards,
Tom Ogilvy

"Ed" wrote in message
...
Tom, thanks for the help. I am having some problems, though.

How do I set a reference to all my CommandBar Buttons?
Isn't "Next" the end of a loop? What starts the loop? What did I miss?

Ed

"Tom Ogilvy" wrote in message
...
Loop through your commandbars and the controls on the commandbars,

test
the
onaction property to see if it contains a reference to the new file

and
if
so, change it back by modifying the string (onaction property value)

and
assigning it back to the onaction property.

sPath = "C:\Program Files\Microsoft

Office\Office\xlStart\Personal.xls"

'start of loop

if obj.onaction < "" then
if instr(1,.obj.onaction,"C:\My folder\myfile.xls",vbTextCompare)

then
obj.onaction = Application.Substitute(obj.Onaction,"C:\My
Folder\myfile.xls",sPath)
end if
end if

next obj

where obj is a reference to your commandbar button.

--
Regards,
Tom Ogilvy

"Ed" wrote in message
...
I launched Excel and got a blank workbook. Actually, it was my
Personal.xls, but it was blank. So I typed in it and SavedAs a new

name.
Now all my macros want the file I SavedAs, not Personal.xls!! I can
right-click on my toolbars to get Customize, then right-click on a

macro
button to see the Assign(ed) Macro, and it's pointing to this other

file.
I
deleted it, and restarted, but it didn't help. All the modules are

still
in
Personal. How do I change back 34 modules?

Ed










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
Oops sent to wrong forum: Excel Macros Dar Excel Discussion (Misc queries) 1 March 2nd 10 05:46 PM
Make custom buttons point to local macros always Fabian Excel Discussion (Misc queries) 2 May 6th 09 03:24 PM
Why do hyperlinks in excel 2007 point to the wrong place after so. Geoff Excel Discussion (Misc queries) 0 October 10th 08 03:52 PM
causing macros to run at insertion point Inobugs Excel Worksheet Functions 3 February 1st 06 06:19 AM
I keep losing saved Excel macros, what am I doing wrong? GTNet_Boss New Users to Excel 2 October 27th 05 11:01 PM


All times are GMT +1. The time now is 09:39 AM.

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

About Us

"It's about Microsoft Excel"