3

I have a vb6 app that uses Word interop to create a few reports. In the introduction of these reports, there are some instructions in 4 textboxes around an image.

Recently and suddenly the top two textboxes started appearing on the next page, and I can't figure out why. When I step through the code and watch the word document getting built, everything positions itself correctly, however, if I compile the application, the error reappears.

Any suggestions?

Christian Wattengård
  • 5,543
  • 5
  • 30
  • 43
  • 4
    It's kind of impossible to troubleshoot this with no code or more details. For example, are you using A4 size paper in your tests but Letter in your compiled version (i.e. Word defaults for American market)? The repositioning of the textboxes is probably related to to margins, float characteristics and paper size. If you could provide more details, we could likely come up with an answer/solution. – Todd Main Dec 04 '10 at 18:09
  • Usint Word com interop it opens a premade .DOT-file, fills it with data, prints to pdf, and closes it. It opens the same .DOT-file in debug and compiled, and it does not mess with paper-settings or anything. – Christian Wattengård Dec 05 '10 at 22:33

4 Answers4

1

Use late-bound calls to Word. This does not mean to remove reference to Microsoft Word Xxx Object Library, just alter your Dims like this

Dim oWord As Object '--- was Word.Application'
Dim oDoc As Object '--- was Word.Document'
...
oDoc.Protect wdAllowOnlyReading '--- keep using enums'
wqw
  • 11,771
  • 1
  • 33
  • 41
0

Could it be some 'rounding' difference? For instance if you compare two float point values for equality, the result can subtly depend on the specific compiler/interpreter implementation.

I would like to suggest to trim down your code to the minimum showing the different behaviors. That might clear things up already. If not, please post it here to let us help you.

Michel de Ruiter
  • 7,131
  • 5
  • 49
  • 74
0

Maybe you are running the compiled version as a different user than the one running VB when you debug? Maybe this could cause what you are describing, if the two users have some different Word settings.

Is it possible that the compiled version finds a different version of the .dot file?

It may be very helpful if you show the code you use to create the Word document, because then someone here might notice something that can be sensible to moving to a compiled version.

Ran
  • 5,989
  • 1
  • 24
  • 26
0

Do you have any code in events that rely on timing, such as Form_Activate, Load, or Unload? I've seen those things behave very differently when stepping through code and when compiled, especially on newer, faster machines.

Ryan
  • 702
  • 1
  • 5
  • 11