Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Out of range error

Status
Not open for further replies.

KatyWhite

Technical User
Jan 15, 2004
16
US
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!
 
I'm guessing it has to do with the automation (perhaps some implicit referencing creating anomalities?). Have you tried to perform all the needed formatting from VB, and not call the Word macro?

Roy-Vidar
 
Hi RV, no I have not tried doing that ... I will give that a shot. I think it has to do with the automation as well ..
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top