P
peturg
I am trying to using the code below to insert paragraphs into Word
documents based on the information in an Excel worksheets
.....
Dim myWB As Excel.Workbook
Dim myCell as String
Set myWB = GetObject("{path}\filename.xls")
With myWB.Application
.GoTo Reference:="RangeName"
myCell = .ActiveCell.Value
If myCell = "SomeValue" Then
NormalTemplate.AutoTextEntries("CannedText").Insert _
Where:=ActiveDocument.Paragraphs(n).Range
Else
End If
End With
....
The code works with workbook-level names. However, I am having
trouble pointing it to worksheet-level names: changing "RangeName" to
"'Sheet'!RangeName" hasn't worked.
(Ultimately, I want to iterate through RangeName 1-n. I also want to
iterate through sheets, generating and saving one word doc per sheet.)
Do I need to activate the sheet before calling the name? How is that
done? Should I be using a different kind of conditional statement?
Thanks in advance,
Petur G
documents based on the information in an Excel worksheets
.....
Dim myWB As Excel.Workbook
Dim myCell as String
Set myWB = GetObject("{path}\filename.xls")
With myWB.Application
.GoTo Reference:="RangeName"
myCell = .ActiveCell.Value
If myCell = "SomeValue" Then
NormalTemplate.AutoTextEntries("CannedText").Insert _
Where:=ActiveDocument.Paragraphs(n).Range
Else
End If
End With
....
The code works with workbook-level names. However, I am having
trouble pointing it to worksheet-level names: changing "RangeName" to
"'Sheet'!RangeName" hasn't worked.
(Ultimately, I want to iterate through RangeName 1-n. I also want to
iterate through sheets, generating and saving one word doc per sheet.)
Do I need to activate the sheet before calling the name? How is that
done? Should I be using a different kind of conditional statement?
Thanks in advance,
Petur G