My Macro Suddenly is not Working

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

When I run my macro in the template, it works fine, but when i save the
template document as something else it stops working. Does anyone have any
insight? Thank you.
 
I think we'll need more details.

Did you check to see if the macro is in the new file? Depending on how you
applied the template, it might not have transferred the macro.

Do you have macro security set to Medium or Low? Macros won't run with High
Security.

What did you name the new file? VBA doesn't like certain file names,
particularly those with exclamation points in them.

--David

--
David M. Marcovitz
Microsoft PowerPoint MVP
Director of Graduate Programs in Educational Technology
Loyola College in Maryland
Author of _Powerful PowerPoint for Educators_
http://www.PowerfulPowerPoint.com/
 
Here is my macro. I think you actually helped me get it working last time. It
was named Template Deck.ppt, I renamed it to Project Legion 3-8-07.ppt. Does
it look like the name could be the problem? Also, the excel file this ppt has
links to was renamed in the same way and they were saved together in a folder
on another drive. They went from a shared drive to the C: drive on my
computer.

Sub HyperLinkSearchReplace()
'
'
Dim oSl As Slide
Dim oHl As Hyperlink
Dim sSearchFor As String
Dim sReplaceWith As String
Dim oSh As Shape

sSearchFor = InputBox("What text should I search for?", "Search for ...")
If sSearchFor = "" Then
Exit Sub
End If

sReplaceWith = InputBox("What text should I replace" & vbCrLf _
& sSearchFor & vbCrLf _
& "with?", "Replace with ...")
If sReplaceWith = "" Then
Exit Sub
End If

For Each oSl In ActivePresentation.Slides

For Each oHl In oSl.Hyperlinks
oHl.Address = Replace(oHl.Address, sSearchFor, sReplaceWith)
oHl.SubAddress = Replace(oHl.SubAddress, sSearchFor, sReplaceWith)
Next ' hyperlink

' and thanks to an astute user on the PPT Newsgroup, lets fix OLE
links too
For Each oSh In oSl.Shapes
If oSh.Type = msoLinkedOLEObject Then
oSh.LinkFormat.SourceFullName = _
Replace(oSh.LinkFormat.SourceFullName, _
sSearchFor, sReplaceWith)
End If
Next

Next ' slide

End Sub
 
If the macro works in the template, the problem probably isn't in the
macro itself. Have you changed any other code in the new file? Have you
tried renaming the file to something simple like test.ppt (it doesn't
look like that is the problem, but it will take you two seconds to find
out)? Have you tried running any other code? I would try typing in a
simple procedure like:

Sub SayHello()
MsgBox "Hello"
End Sub

and running that. Try putting it in the template and try creating a new
file from the template, and just try putting it directly in the new file.
I would want to know if any code is running at all in the new file
(either code added directly to the new file or code brought over from the
template).

--David

--
David M. Marcovitz
Microsoft PowerPoint MVP
Director of Graduate Programs in Educational Technology
Loyola College in Maryland
Author of _Powerful PowerPoint for Educators_
http://www.PowerfulPowerPoint.com/
 
I have not changed any code in the new file. I am thinking the problem might
have something to do with moving the location of the files. That's the only
time the Macro has a problem. Do you know if perhaps there could be something
wrong with moving the file between drives?
 
That's why I want to know if you can run any code in the new file. As you
mess with OLE links that could be broken, it would help to see if the
problem is with code in general not being able to run on the new file or
something specific in your code. If you put a simple Hello macro in your
new file, and it doesn't work, we can stop blaming your code and look for
another source of the problem. If it does work, we can try to figure out
what's wrong with your code.
--David

--
David M. Marcovitz
Microsoft PowerPoint MVP
Director of Graduate Programs in Educational Technology
Loyola College in Maryland
Author of _Powerful PowerPoint for Educators_
http://www.PowerfulPowerPoint.com/
 
When I run my macro in the template, it works fine, but when i save the
template document as something else it stops working. Does anyone have any
insight? Thank you.

What does "stops working" mean, exactly?

Nothing happens when you try to run it?
If so, how are you trying to run it? Give us the steps you're following.

It runs, but bad things happen? Smoke? Flames? Error messages?
 
Ok, well now I put that macro in there and the screen is just bliniking. I
hope something's not messed up now.
 
When I say not working, I mean the links don't update like the macro is
supposed to and i get an error message - something about source name
notworking.
 
When I say not working, I mean the links don't update like the macro is
supposed to and i get an error message - something about source name
notworking.

First step in tracking down ANY kind of computer problem: write down the EXACT
text of the error message and paste it in here verbatim.

Without exact information, the best we can suggest for "something about" error
messages is that you do "something about" fixing 'em. ;-)
 
Back
Top