Solved

VBA script error

Posted on 2013-06-27
4
235 Views
Last Modified: 2013-07-03
When I run the following, I get an error only when twosided = false.  It runs normally when twosided = true.
If xlSheet.Range("PFNumSides") = "2" Then
            twosided = True
        Else
            twosided = False
        End If
        
    'Page cover - ink
    For i = 1 To wdDoc.ContentControls.Count
        If wdDoc.ContentControls(i).Title = "inks1" Then
            If xlSheet.Range("PrintFoldColor").Text = "Color/Black&White" Then
                wdDoc.ContentControls(i).Range.Text = "4/1"
            Else
                If xlSheet.Range("printFoldColor").Text = "Color" Then
                    If twosided = True Then
                        wdDoc.ContentControls(i).Range.Text = "4/4"
                    Else
                        wdDoc.ContentControls(i).Range.Text = "4/0"
                    End If
                    Exit For
                Else
                    If twosided = True Then
                        wdDoc.ContentControls(i).Range.Text = "1/1"
                    Else
                        wdDoc.ContentControls(i).Range.Text = "1/0"
                    End If
                    Exit For
                End If
                Exit For
            End If
            Exit For
        End If
    Next

Open in new window

The error says "Automation error Call was rejected by callee."
Any ideas?
0
Comment
Question by:mjburgard
  • 3
4 Comments
 
LVL 65

Expert Comment

by:RobSampson
ID: 39283385
What type of object is that content control?  Maybe it's trying to interpret it literally as a division by zero.

Try
wdDoc.ContentControls(i).Range.Text = CStr("4/0")

Rob.
0
 
LVL 1

Author Comment

by:mjburgard
ID: 39284513
Thanks rob, but that is going into a microsoft word document as text. - and last night it mysteriously started working - I have no explanations at this point.

I am going to mark this as completed - but ...
0
 
LVL 1

Accepted Solution

by:
mjburgard earned 0 total points
ID: 39284524
Last night - the macro suddenly started working - I have no explanation as to why - just that it has.

Nothing changed, no code was changed, The only possibility is that a new instance of excel was opened - but I am not even sure about that as I had opened and closed the spreadsheet multiple times before.

Marking this one finished, but with no understanding of why it was happening in the first place.
0
 
LVL 1

Author Closing Comment

by:mjburgard
ID: 39295993
If you read my previous comment, you will see that it just started working last night.

I still have no idea why, but I no longer have a problem if it is working.
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Recently I finished a vbscript that I thought I'd share.  It uses a text file with a list of server names to loop through and get various status reports, then writes them all into an Excel file.  Originally it was put together for our Altiris server…
This is an addendum to the following article: Acitve Directory based Outlook Signature (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_24950055.html) The script is fine, and works in normal client-server domains…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now