Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Need help with macro If and Else statements
I have a macro that cleans up documents (non-breaking spaces, etc.) and I'm
trying to get it to look for footnotes and clean them up but if no footnotes just clean the document text. FOOTNOTESCAN changes the view to Normal, selects View Footnote then cleans them up and returns to page 1 of the document and then runs CLEAN macro to clean the text. CLEAN just cleans the text and doesn't look for footnotes. Each macro runs fine by itself but I can't connect them to run in one macro. In LOOKFOR below I've tried having it look for the footnote mark in the text and then run the other macros. No luck. If I run FOOTNOTESCAN in a document that has no footnotes, it doesn't work and I get an error msg. LOOKFOR macro only cleans the text and ignores FOOTNOTESCAN. Sub FootnoteScan() ' ' FootnoteScan Macro ' Macro recorded 2/5/2009 by VL_Jackson ' If ActiveWindow.View.SplitSpecial = wdPaneNone Then ActiveWindow.ActivePane.View.Type = wdPrintView Else ActiveWindow.View.Type = wdNormalView End If If ActiveWindow.ActivePane.View.Type = wdPrintView Or ActiveWindow. _ ActivePane.View.Type = wdWebView Or ActiveWindow.ActivePane.View.Type = _ wdPrintPreview Then ActiveWindow.View.SeekView = wdSeekFootnotes Else ActiveWindow.View.SplitSpecial = wdPaneFootnotes End If If ActiveWindow.View.SeekView = wdPaneFootnotes Then Application.Run MacroName:="CLEAN" Else ActiveWindow.ActivePane.View.Type = wdPrintView End If Call GOTOPAGE End Sub LOOKFOR Selection.Find.ClearFormatting With Selection.Find .Text = "^f" .Forward = True .Wrap = wdFindContinue .Format = False .MatchCase = False .MatchWholeWord = False .MatchWildcards = False .MatchSoundsLike = False .MatchAllWordForms = False If Text = "^f" Then Call FootnoteScan Else Call CLEAN End If End With End Sub -- Ginny |
#2
Posted to microsoft.public.word.docmanagement,microsoft.public.word.vba.general
|
|||
|
|||
Need help with macro If and Else statements
Ginny,
You would probably have better luck asking this question in the Programming newsgroup (microsoft.public.word.vba.general), but I've cross-posted my answer there to see if anyone else wants to chip in. Try something like this: Sub CleanUpMyDocument CLEAN If Footnotes.Count 1 Then FootnoteScan GOTOPAGE End Sub This should work assuming that all code is in the same module and there are no bugs in any of the other procedures that will cause the code to hang. -- Cheers! Gordon Bentley-Mix Word MVP Uninvited email contact will be marked as SPAM and ignored. Please post all follow-ups to the newsgroup. "Ginny" wrote: I have a macro that cleans up documents (non-breaking spaces, etc.) and I'm trying to get it to look for footnotes and clean them up but if no footnotes just clean the document text. FOOTNOTESCAN changes the view to Normal, selects View Footnote then cleans them up and returns to page 1 of the document and then runs CLEAN macro to clean the text. CLEAN just cleans the text and doesn't look for footnotes. Each macro runs fine by itself but I can't connect them to run in one macro. In LOOKFOR below I've tried having it look for the footnote mark in the text and then run the other macros. No luck. If I run FOOTNOTESCAN in a document that has no footnotes, it doesn't work and I get an error msg. LOOKFOR macro only cleans the text and ignores FOOTNOTESCAN. Sub FootnoteScan() ' ' FootnoteScan Macro ' Macro recorded 2/5/2009 by VL_Jackson ' If ActiveWindow.View.SplitSpecial = wdPaneNone Then ActiveWindow.ActivePane.View.Type = wdPrintView Else ActiveWindow.View.Type = wdNormalView End If If ActiveWindow.ActivePane.View.Type = wdPrintView Or ActiveWindow. _ ActivePane.View.Type = wdWebView Or ActiveWindow.ActivePane.View.Type = _ wdPrintPreview Then ActiveWindow.View.SeekView = wdSeekFootnotes Else ActiveWindow.View.SplitSpecial = wdPaneFootnotes End If If ActiveWindow.View.SeekView = wdPaneFootnotes Then Application.Run MacroName:="CLEAN" Else ActiveWindow.ActivePane.View.Type = wdPrintView End If Call GOTOPAGE End Sub LOOKFOR Selection.Find.ClearFormatting With Selection.Find .Text = "^f" .Forward = True .Wrap = wdFindContinue .Format = False .MatchCase = False .MatchWholeWord = False .MatchWildcards = False .MatchSoundsLike = False .MatchAllWordForms = False If Text = "^f" Then Call FootnoteScan Else Call CLEAN End If End With End Sub -- Ginny |
Reply |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
If statements | Mailmerge | |||
quotations within IF statements? | Microsoft Word Help | |||
If then statements | Mailmerge | |||
IF statements with footers | Mailmerge | |||
IF Fields With AND Statements | Microsoft Word Help |