Solved

vbCrLf vs. Office 2007

Posted on 2009-04-08
8
322 Views
Last Modified: 2012-05-06
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
Comment
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
8 Comments
 
LVL 92

Expert Comment

by:Patrick Matthews
ID: 24096746
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
 
LVL 3

Author Comment

by:QualitySoftwareDevelopment
ID: 24096818
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
 
LVL 92

Expert Comment

by:Patrick Matthews
ID: 24096897
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
Technology Partners: 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!

 
LVL 19

Expert Comment

by:dlc110161
ID: 24097610
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
 
LVL 19

Accepted Solution

by:
dlc110161 earned 500 total points
ID: 24111869
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
 
LVL 3

Author Comment

by:QualitySoftwareDevelopment
ID: 24113743
Thx to all I'm back at the office on Thueday where I'll test your results
0
 
LVL 3

Author Closing Comment

by:QualitySoftwareDevelopment
ID: 31567935
... and it actually also works with vbCrLf, thx!
0

Featured Post

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

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

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
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…
This video teaches the viewer how to align pictures around text while keeping the text properly aligned in the document.
Learn how to create and modify your own paragraph styles in Microsoft Word. This can be helpful when wanting to make consistently referenced styles throughout a document or template.

734 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