Solved

Automating Word - Error on Users Machine, Can't Duplicate On Mine

Posted on 2012-03-09
5
244 Views
Last Modified: 2012-08-14
I am developing an application that creates (from scratch) a Word document.  I'm developing using VB.Net 2010 (Pro).  I have on my machine MS Office 2010, the user has Office 2003, so I'm using late binding.

Here is the block of code that's failing
    Dim shp As Object = oTable.Cell(1, 1).Range.InlineShapes.AddPicture(sBMPFile)
    With shp
        writeLog("Adjust Image Size", "clsReport", "writePage05")
        .LockAspectRatio = 1
        Dim fOldWidth As Single = .Width
        writeLog("Adjust Image Width", "clsReport", "writePage05")
        .Width = m_oWord.InchesToPoints(4)
        If .Height > m_oWord.InchesToPoints(4.5) Then
            writeLog("Adjust Image Height", "clsReport", "writePage05")
            .Height = m_oWord.InchesToPoints(4.5)
        End If
    End With

Open in new window


Specifically, I have localized the error to occur at the "LockAspectRatio" line, or the line after.

The error that's thrown is this:
See the end of this message for details on invoking 
just-in-time (JIT) debugging instead of this dialog box.

************** Exception Text **************
System.ArgumentException: The specified value is out of range.
   at Microsoft.VisualBasic.CompilerServices.LateBinding.InternalLateSet(Object o, Type& objType, String name, Object[] args, String[] paramnames, Boolean OptimisticSet, CallType UseCallType)
   at Microsoft.VisualBasic.CompilerServices.NewLateBinding.LateSet(Object Instance, Type Type, String MemberName, Object[] Arguments, String[] ArgumentNames, Type[] TypeArguments, Boolean OptimisticSet, Boolean RValueBase, CallType CallType)
   at STR_Tower_Mapping_Report_Maker.clsReport.writePage_05()

Yada, yada, yada

Open in new window


I'm fairly certain the issue is the fact that the "LockAspectRatio" value should be "msoTrue", but since I'm late binding I'm merely guessing at the actual numeric value.

Any ideas?
0
Comment
Question by:Clif
5 Comments
 
LVL 6

Expert Comment

by:Patrick Tallarico
ID: 37703521
My suspicion is that it may be calling this from a vba library that your users may not have loaded.  Open the VBA console, and go to 'Tools' -> 'References' and check to make sure that the libraries you have on your machine are checked for your users.
0
 
LVL 83

Accepted Solution

by:
CodeCruiser earned 500 total points
ID: 37703548
0
 
LVL 40
ID: 37703659
If the error is on line 5, remove it, you do not use that variable anywhere in your code.

You might want to provide the use with Word 2003 with a Debug version of the application. You would get more information out of the error report.

However, as it is, it gives a clue. Look at the last line, this is typically the line that triggered the error:

at STR_Tower_Mapping_Report_Maker.clsReport.writePage_05()

What is that STR_Tower_Mapping_Report_Maker?
0
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 37703731
The constant msoCTrue has a value of 1. msoTrue is -1, so that is the value to use

msoCTrue produces the error on my 2003 version.
0
 
LVL 10

Author Closing Comment

by:Clif
ID: 37729726
Sorry it took so long to get back, but the user was out of the office for a few days, so they couldn't test it.

The change from 1 to -1 did the trick.

Thanks.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Populating an array of locale_time_info 8 37
PowerPoint Links 7 37
SQL syntax in VB.net 5 28
Handle KeyDown for ToolStripDropDownButton, ToolStripMenuItem 3 18
Preface: When I started this series, I used the term CommandBars because that is the Office Object class that it discusses. Unfortunately, when Microsoft introduced Office 2007, they replaced the standard Commandbar menus with "The Ribbon" and rem…
No matter the version of Windows you are using, you may have some problems with Windows Search running too slow or possibly not running at all. Before jumping into how you can solve this issue, just know there are many other viable alternative deskt…
This video shows where to find the word count, how to display it, and what it breaks down to in Microsoft Word.
The viewer will learn how to simulate a series of sales calls dependent on a single skill level and learn how to simulate a series of sales calls dependent on two skill levels. Simulating Independent Sales Calls: Enter .75 into cell C2 – “skill leve…

932 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

12 Experts available now in Live!

Get 1:1 Help Now