How JustAnswer Works:
  • Ask an Expert
    Experts are full of valuable knowledge and are ready to help with any question. Credentials confirmed by a Fortune 500 verification firm.
  • Get a Professional Answer
    Via email, text message, or notification as you wait on our site.
    Ask follow up questions if you need to.
  • 100% Satisfaction Guarantee
    Rate the answer you receive.
Ask Pete Your Own Question
Pete
Pete, Computer Engineer
Category: Programming
Satisfied Customers: 17021
Experience:  Over 16 years of experience in computer programming.
30970729
Type Your Programming Question Here...
Pete is online now
A new question is answered every 9 seconds

I have an Excel spreadsheet that has a list of customers,

Customer Question

I have an Excel spreadsheet that has a list of customers, products they have purchased and options they have selected. I have word documents discussing each product and option. I need to be able to select a customer and have excel build a manual based upon the product and options for the customer.
So far, I have code that will create a work document beginning with a cover page and TOC. It then appends each appropriate the product and option documents just fine. The problem is the footers need to be changed so the first one does not copy the TOC footer, has numeric number and starts with 1 while all after do copy from the one before.
When I run the code I get on the "With WordApp.Selection" line an error 'Object variable or with block variable not set'. I have tried every combination of this the I can.
For I = 3 To selList + 1
.Selection.GoTo What:=wdGoToSection, Which:=wdGoToFirst, Count:=3, Name:=""
.Selection.Find.ClearFormatting
If I = 3 Then
.ActiveDocument.Sections(3).Footers(1).LinkToPrevious = False
With WordApp.Selection.HeaderFooter.PageNumbers
.NumberStyle = wdPageNumberStyleArabic
.HeadingLevelForChapter = 0
.IncludeChapterNumber = False
.ChapterPageSeparator = wdSeparatorHyphen
.RestartNumberingAtSection = True
.StartingNumber = 1
End With
Else
.ActiveDocument.Sections(I + 1).Footers(1).LinkToPrevious = True
With .Selection.HeaderFooter.PageNumbers
.NumberStyle = wdPageNumberStyleArabic
.HeadingLevelForChapter = 0
.IncludeChapterNumber = False
.ChapterPageSeparator = wdSeparatorHyphen
.RestartNumberingAtSection = False
.StartingNumber = 0
End With
End If
Next I
Submitted: 7 months ago.
Category: Programming
Expert:  Pete replied 7 months ago.

Hi, I'm Pete. Welcome to JustAnswer! I'm reviewing your question now, and will post back with your reply ASAP.

Expert:  Pete replied 7 months ago.

Bill, this error can occur if a variable was declared without specifying a type.

For example, if a variable is declared without specifying a type, it defaults to type 'Object'.

If you have previously declared the variable type, then you may be attempting to reference an object that has been set to 'Nothing'.