View Single Post
 
Old 07-14-2011, 03:56 PM
macropod's Avatar
macropod macropod is online now Windows 7 64bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,384
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Hi chipnputt,

I've had a quick look at your 'ExportToWord' sub. There are some odd things there, plus some inefficiencies that could be improved upon. For example:
1. Why do you have:
Code:
If Err.Number <> 0 Then 'Word isn't already running
End If
and:
Code:
ActiveDocument.Protect Type:=wdAllowOnlyFormFields, NoReset:=True
ActiveDocument.Unprotect
Neither of these seem to do anything useful.

2. The code:
Code:
  If i = 2 Then
    DaySheet = "Monday"
  End If
  If i = 3 Then
    DaySheet = "Tuesday"
  End If
  If i = 4 Then
    DaySheet = "Wednesday"
  End If
  If i = 5 Then
    DaySheet = "Thursday"
  End If
  If i = 6 Then
    DaySheet = "Friday"
  End If
  If i = 7 Then
    DaySheet = "Saturday"
  End If
would be simpler and more efficicent as:
Code:
  Select Case i
    Case i = 2: DaySheet = "Monday"
    Case i = 3: DaySheet = "Tuesday"
    Case i = 4: DaySheet = "Wednesday"
    Case i = 5: DaySheet = "Thursday"
    Case i = 6: DaySheet = "Friday"
    Case i = 7: DaySheet = "Saturday"
  End Select
and, notwithstanding that I've demonstrated that copying & pasting is unnecessary for what you're doing:
Code:
  Worksheets(DaySheet).Activate
  Worksheets(DaySheet).Range(BmTeamName).Select
  Selection.Copy
would be simpler and more efficicent as:
Code:
Worksheets(DaySheet).Range(BmTeamName).Copy
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote