Thank you for being a valued part of the CNET community. As of December 1, 2020, the forums are in read-only format. In early 2021, CNET Forums will no longer be available. We are grateful for the participation and advice you have provided to one another over the years.

Thanks,

CNET Support

General discussion

Word 2003 VBA versus Word 2007 VBA

Jun 25, 2010 6:45AM PDT

I have created a Visual Basic program in 0ffice 2003 which runs very fast, but when running the same program in Office 2007, it is very slow (unacceptable), yet I can find no issues to correct this.
Can someone please help???? Remote assistance would be great.

Discussion is locked

- Collapse -
Re: VBA in Office 2003 and Office 2007
Jun 25, 2010 6:54AM PDT

That speed difference is in the same account on the same machine?
What does the program (macro?) do? Can you show the source?

Kees

- Collapse -
word macro
Jun 25, 2010 10:02AM PDT

Thanks for the reply. The program or macro is pretty large to show here, but it is with the same account, same pc, etc.

Could you possibly remote into my pc and see things for yourself?

- Collapse -
For that ...
Jun 25, 2010 6:31PM PDT

we have paid expert support. Just click on the picture in the left column.

Personally, I don't have the faintest idea what could be the cause. So having me for such support wouldn't be a good idea.

I googled VBA OFFICE 2007 SLOW and got a lot of hits. The first was http://www.codeforexcelandoutlook.com/blog/2009/03/excel-vba-performance-in-office-2007/ but only covers Excel. In Word, Access, Powerpoint there might be other causes. Just "Office 2007" tells practically nothing.

Kees

- Collapse -
Yep I agree with Kees.
Jun 25, 2010 9:41PM PDT

You said Visual Basic program in Word 2003. Do you mean a VB Macro?

If so, as you cannot copy/paste the full macro into a post here, can you give some idea what the macro does?

For example, although Word 2007 has backwards compatibility, it handles documents in a .docx format and not just .doc, so if your macro is designed for manipulating .doc files, there may be some conversion that the macro has to do before it can work through itself.

There are other major differences between Office 2003 and Office 2007, and these may affect macro writing.

If you have now switched over wholly to Office/Word 2007, you may be better off re-writing the macro using 2007's VBA editor.

The VBA editor has a Debug option. Perhaps you could use that to step through each line of code?

Mark

- Collapse -
...
Jun 26, 2010 1:04AM PDT

I should have mentioned that I am running the Office 2007 on a Windows 7 machine, but the issue is the same on an XP machine. Also, the Office 2003 runs flawless on either OS (XP or Win7).

This is a very large and complicated application which was developed in the 2003 VB enviroment, so I wouldn't want to refer to it as a macro. I have saved the program in a .bas format, but i see no provision here to append a file. A copy and paste would be impractical due to size and the requirement of many supporting external documents.

In the simplest explanation as to what I am doing, the program scores a test that has been taken online, opens a blank forms document and writes the results into this document.

Following is a short section of the code that seems to be the slowest link. I wish I could include the blank form page which this section is working with. So is there a way to include attachments here?


(I tried pasting a copy of the form that is being filled out by this code but it was useless as it doesn't show the table structure.)
Added note: For the most part, the noscore code never runs so it is not the issue.

For x = 1 To ab
If test_score(x) = 0.5 Then GoTo noscore

Selection.GoTo What:=wdGoToBookmark, Name:="p11score" + LTrim$(Str(x))
ActiveDocument.FormFields("p11score" + LTrim(Str(x))).Result = test_score(x)
numtabs = test_score(x) * 2 + 3
Selection.MoveRight Unit:=wdCell, Count:=numtabs
Selection.Shading.Texture = wdTexture40Percent
Selection.MoveRight Unit:=wdCell
Selection.Shading.Texture = wdTexture40Percent
noscore:
If job_fam$ > "" Then
Selection.GoTo What:=wdGoToBookmark, Name:="p11score" + LTrim$(Str(x))
If hi(x) > 0 Then
numtabs = low(x) * 2 + 3
Selection.MoveRight Unit:=wdCell, Count:=numtabs
If WordBasic.ShadingPattern() = 7 Then
Selection.Shading.Texture = wdTexture50Percent
Else
Selection.Shading.Texture = wdTexture25Percent
End If
For z = 1 To ((hi(x) - low(x)) * 2 + 1)
Selection.MoveRight Unit:=wdCell
If WordBasic.ShadingPattern() = 7 Then
Selection.Shading.Texture = wdTexture50Percent
Else
Selection.Shading.Texture = wdTexture25Percent
End If
Next z
End If
End If

Next x


(this is ugly but gives some vague idea)
Name: David Van Straten
ID: CCode / QNNTG3LF

Position: Attorney
Company: U.S. Venture, Inc.

HP:
VP: 50 / 2

NSight

- Collapse -
"anything happening to the GUI is very slow in 2007"
Jun 26, 2010 1:12AM PDT
- Collapse -
Thanks Bob
Jun 26, 2010 1:33AM PDT

Thanks for the reply, Bob.

This is probably the bottom line, so I quess the option would be to always have 2003 available for this application at least.

Kinda suks, huh!

- Collapse -
There is some good stuff in that and other discussions.
Jun 26, 2010 2:31AM PDT

I really like that Application.updating call. I can see where that will help me out on my next macro.
Bob

- Collapse -
That Application.ScreenUpdating=False
Jun 26, 2010 5:03AM PDT

sounds a good idea, and the discussion in that link Bob gave looks interesting.

There are a few suggestions there, and ones I found intriguing were the 're-saving' the file which dropped the file size down, and the "stripping out" any html code.

May be you can find something there that helps.

Mark

- Collapse -
Application.ScreenUpdating=False
Jun 28, 2010 5:22AM PDT

Thanks to all for the help on this issue.

Disallowing Screenupdating improved the macro speed to an acceptable level, but still much slower than the 2003 performance.

I wonder if 2010 will have the same slow GUI macro issues.