wagnet
05-08-2006, 12:07 PM
Geeez.....seems like it should be so easy.
From an Excel macro, I'm trying to:
1) open a Word document
2) put the FormField value into an array
3) close out Word
4) ...then from another macro, use the array values to populate an Excel Spreadsheet
Currently, I'm stuck on the Documents.Open command - runtime error 424.
The Array population routine was copy/paste from a working Word macro.
Dim MyArray(24, 2) As Integer
Sub ConvertSCQ()
Set WordApp = CreateObject("Word.Application")
fileToOpen = Application _
.GetOpenFilename("Word Files (*.doc), *doc")
WordApp.Visible = False
Documents.Open (fileToOpen)
Stop
aRay = 0
aField = 1
Do
If ActiveDocument.FormFields(aField).Name = "State" Then
aRay = aRay + 1
MyArray(aRay, 1) = ActiveDocument.FormFields(aField).Name
MyArray(aRay, 2) = ActiveDocument.FormFields(aField).Result
End If
aField = aField + 1
Loop Until aField = 25
WordApp.Quit SaveChanges:=wdDoNotSaveChanges
Set WordApp = Nothing
End Sub
Edited 9-May-06 by GeekGirlau. Reason: Insert vba tags.
From an Excel macro, I'm trying to:
1) open a Word document
2) put the FormField value into an array
3) close out Word
4) ...then from another macro, use the array values to populate an Excel Spreadsheet
Currently, I'm stuck on the Documents.Open command - runtime error 424.
The Array population routine was copy/paste from a working Word macro.
Dim MyArray(24, 2) As Integer
Sub ConvertSCQ()
Set WordApp = CreateObject("Word.Application")
fileToOpen = Application _
.GetOpenFilename("Word Files (*.doc), *doc")
WordApp.Visible = False
Documents.Open (fileToOpen)
Stop
aRay = 0
aField = 1
Do
If ActiveDocument.FormFields(aField).Name = "State" Then
aRay = aRay + 1
MyArray(aRay, 1) = ActiveDocument.FormFields(aField).Name
MyArray(aRay, 2) = ActiveDocument.FormFields(aField).Result
End If
aField = aField + 1
Loop Until aField = 25
WordApp.Quit SaveChanges:=wdDoNotSaveChanges
Set WordApp = Nothing
End Sub
Edited 9-May-06 by GeekGirlau. Reason: Insert vba tags.