Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 330
  • Last Modified:

vbCrLf vs. Office 2007

Hi,
I have made a worddocumentgenerator in VB through Access. It works great in word 2003, but since word 2007 it has change the events.

I have tried to to replace the vbCrLf with both Chr(10) and Chr (13) but without any luck

Any ideas?
0
QualitySoftwareDevelopment
Asked:
QualitySoftwareDevelopment
  • 3
  • 2
  • 2
1 Solution
 
Patrick MatthewsCommented:
QualitySoftwareDevelopment said:
>>Any ideas?

Not sure what the trouble is, but vbCrLf is equivalent to Chr(13) & Chr(10), in that order.

Perhaps if you posted the code the situation would become clearer...
0
 
QualitySoftwareDevelopmentAuthor Commented:
The code is
InsertAfter "FIRMNAME" & vbCrLf & "Rapport no." & " " & rsRapport("Rapportnr")

I then tried to replace the vbCrLf with Chr(13) which didn't work and then after that I replaced it with Chr(10) which didn't help either.

The problem:
In word 2003 the output is:
----
FIRMNAME The Firm
Rapport no. 10002
----

In Word 2007 the output is:
----
FIRMNAME The Firm

Rapport no. 10002
----

and I need it to be as in 2003

The case is that in word 2003 you get the lineshiftas above with a RETURN, but to get the same lineshift in word 2007 you have to use SHIFT-RETURN
0
 
Patrick MatthewsCommented:
QualitySoftwareDevelopment said:
>>I then tried to replace the vbCrLf with Chr(13) which didn't work and then after that I replaced it with Chr(10) which didn't help either.

As I stated in my first comment, vbCrLf is equivalent to Chr(13) & Chr(10)...

InsertAfter "FIRMNAME" & Chr(13) & Chr(10) & "Rapport no." & " " & rsRapport("Rapportnr")

If that does not solve the problem, I suggest that you use the "request attention" link, and ask the Moderators
to add the Microsoft Word zone to this question.  I dabble in VBA for Word, but there are many *real* Experts
in that zone.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
dlc110161Commented:
The reason your output shows spacing is more than likely due to the Normal style having a spacing of 1.15" in Office 2007. You might have also noticed that the standard font is Calibri rather than TNR. Once you modify the Normal style, your results will be as expected.

Dawn Bleuel
Word MVP
0
 
dlc110161Commented:
Here is some revised code that will insert what you would like done.

Dawn Bleuel
Word MVP
    With Selection.ParagraphFormat
        .SpaceAfter = 0
        .SpaceAfterAuto = False
        .LineSpacingRule = wdLineSpaceSingle
    End With
   Selection.InsertAfter "FIRMNAME" & Chr(13) & Chr(10) & "Rapport no." & " " & rsRapport("Rapportnr")

Open in new window

0
 
QualitySoftwareDevelopmentAuthor Commented:
Thx to all I'm back at the office on Thueday where I'll test your results
0
 
QualitySoftwareDevelopmentAuthor Commented:
... and it actually also works with vbCrLf, thx!
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

  • 3
  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now