Solved

vbCrLf vs. Office 2007

Posted on 2009-04-08
8
319 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
  • 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
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.

 
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

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

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
This video walks the viewer through the process of creating a watermark for their document, customizing it, and saving it for viewing/printing needs.
This video teaches the viewer how to align pictures around text while keeping the text properly aligned in the document.

911 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

24 Experts available now in Live!

Get 1:1 Help Now