L
lestercrombie
The code works until I get to this line:
WrdApp.Selection.Find.Style = ActiveDocument.Styles("Heading 4,SCENE
HEADING")
where an error says that no document is open.
It is clearly open, as WORD has started and I can see the open document
on the screen.
I have added a reference to the WORD library. I've used early
binding.
Why is this error occurring??
My code is below:
Dim WrdApp As Word.Application
Dim WrdDoc As Word.Document
'*********************************
Sub ImportSceneHeadings()
'Input the Script Filename
Call GetScriptFilename
'Start WORD?
Set WrdApp = CreateObject("Word.Application")
WrdApp.Visible = True
'Open the MICROSOFT WORD DOCUMENT
Set WrdDoc = WrdApp.Documents.Open(ScriptFileName)
'Activate WORD document that has been opened. ie the script.
WrdDoc.Activate
'Initialize
EOF = False
j = 1
WrdApp.Selection.StartOf unit:=wdStory 'Move selection point to the
start of the script
'Do a FIND for Heading 4, SCENE HEADING
WrdApp.Selection.Find.ClearFormatting
WrdApp.Selection.Find.Style = ActiveDocument.Styles("Heading 4,SCENE
HEADING") '/
With WrdApp.Selection.Find
..Text = ""
..Replacement.Text = ""
..Forward = True
..Wrap = wdFindStop
..Format = True
..MatchCase = False
..MatchWholeWord = False
..MatchWildcards = False
..MatchSoundsLike = False
..MatchAllWordForms = False
..ParagraphFormat.Borders.Shadow = False
End With
WrdApp.Selection.Find.Style = ActiveDocument.Styles("Heading 4,SCENE
HEADING")
where an error says that no document is open.
It is clearly open, as WORD has started and I can see the open document
on the screen.
I have added a reference to the WORD library. I've used early
binding.
Why is this error occurring??
My code is below:
Dim WrdApp As Word.Application
Dim WrdDoc As Word.Document
'*********************************
Sub ImportSceneHeadings()
'Input the Script Filename
Call GetScriptFilename
'Start WORD?
Set WrdApp = CreateObject("Word.Application")
WrdApp.Visible = True
'Open the MICROSOFT WORD DOCUMENT
Set WrdDoc = WrdApp.Documents.Open(ScriptFileName)
'Activate WORD document that has been opened. ie the script.
WrdDoc.Activate
'Initialize
EOF = False
j = 1
WrdApp.Selection.StartOf unit:=wdStory 'Move selection point to the
start of the script
'Do a FIND for Heading 4, SCENE HEADING
WrdApp.Selection.Find.ClearFormatting
WrdApp.Selection.Find.Style = ActiveDocument.Styles("Heading 4,SCENE
HEADING") '/
With WrdApp.Selection.Find
..Text = ""
..Replacement.Text = ""
..Forward = True
..Wrap = wdFindStop
..Format = True
..MatchCase = False
..MatchWholeWord = False
..MatchWildcards = False
..MatchSoundsLike = False
..MatchAllWordForms = False
..ParagraphFormat.Borders.Shadow = False
End With