Solved

vbCrLf vs. Office 2007

Posted on 2009-04-08
8
318 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
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Nice table. Huge mess. Maybe this was something you created way back before you figured out tabs or a document you received from someone else. Either way, using the spacebar to separate the columns resulted in a mess. Trying to convert text to t…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
In this video, we show how to convert an image-only PDF file into a PDF Searchable Image file, that is, a file with both the image (typically from scanning) and text, which is created in an automated fashion with Optical Character Recognition (OCR) …
This video teaches the viewer how to align pictures around text while keeping the text properly aligned in the document.

707 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

14 Experts available now in Live!

Get 1:1 Help Now