Hi all, I have written a word macro that reformats a document that has been created from many other documents. This document creating portion of the program (in VB6) works fine. However, when I try to call the word macro from VB6 I get "Error 4608 value out of range". Here is the code:
Private Sub cmdFormat_Click()
If ActiveWindow.View.SplitSpecial = wdPaneNone Then
ActiveWindow.ActivePane.View.Type = wdNormalView
Else
ActiveWindow.View.Type = wdNormalView
End If
If optA.Value = True Then 'SAS output Portrait layout
Selection.WholeStory
With ActiveDocument.PageSetup
.TopMargin = InchesToPoints(0.4)<-----
.BottomMargin = InchesToPoints(0.4)
.LeftMargin = InchesToPoints(0.5)
.RightMargin = InchesToPoints(0.5)
.PageWidth = InchesToPoints(8.5)
.PageHeight = InchesToPoints(11)
End With
With Selection.Font
.Name = "Courier New"
.Size = 8
End With
Selection.HomeKey Unit:=wdStory
ElseIf optB.Value = True Then ' similar things etc
the macro craps out when I try and do anything with pagesetup (doesn't matter which item I am trying to change)- it does appear to be selecting the active document, and the values in the margins are 999999 and I'm not sure why that is. I have tried rerecording the macro and the same thing happens.
Can anyone help me ? I could really use some help, I'm stumped! Thanks!
Private Sub cmdFormat_Click()
If ActiveWindow.View.SplitSpecial = wdPaneNone Then
ActiveWindow.ActivePane.View.Type = wdNormalView
Else
ActiveWindow.View.Type = wdNormalView
End If
If optA.Value = True Then 'SAS output Portrait layout
Selection.WholeStory
With ActiveDocument.PageSetup
.TopMargin = InchesToPoints(0.4)<-----
.BottomMargin = InchesToPoints(0.4)
.LeftMargin = InchesToPoints(0.5)
.RightMargin = InchesToPoints(0.5)
.PageWidth = InchesToPoints(8.5)
.PageHeight = InchesToPoints(11)
End With
With Selection.Font
.Name = "Courier New"
.Size = 8
End With
Selection.HomeKey Unit:=wdStory
ElseIf optB.Value = True Then ' similar things etc
the macro craps out when I try and do anything with pagesetup (doesn't matter which item I am trying to change)- it does appear to be selecting the active document, and the values in the margins are 999999 and I'm not sure why that is. I have tried rerecording the macro and the same thing happens.
Can anyone help me ? I could really use some help, I'm stumped! Thanks!