word vba

Public Schedule Face-to-Face & Online Instructor-Led Training - View dates & book

Forum home » Delegate support and help forum » Microsoft VBA Training and help » Word VBA 2010

Word VBA 2010

resolvedResolved · Medium Priority · Version 2010

Josselin has attended:
Excel Advanced course
Excel VBA Intro Intermediate course

Word VBA 2010

Hi,
I have VBA code on Word which shows and hides texts in MS Word but there is a small error in 2 of these buttons and I dont know how to fix it.

The problem seems to be a formatting problem (I am assuming).
The macro hides all the texts but doesnt hide the 1st bullet point at the begining of the text. if I click on the button again, it will show all the texts and bullet points, and if I click again, it will hide all the text and bullet points. I would like the 1st bullet to be hidden to start with.

the problem occurs again if i open this work file again. I still see the 1st bullet point, but all other texts and other bullet point are all hiden. could you help me to fix this issue?

RE: word VBA 2010

Hi Josselin,

Thank you for the question.

Please send me the code you are using.

Thanks


Kind regards

Jens Bonde
Microsoft Office Specialist Trainer

Tel: 0207 987 3777
Best STL - https://www.stl-training.co.uk
98%+ recommend us

London's leader with UK wide delivery in Microsoft Office training and management training to global brands, FTSE 100, SME's and the public sector

Read more: https://www.stl-training.co.uk/post-34560-formula-shows-quarters.html #ixzz2wE8kbKnu

RE: word VBA 2010

The code is:
Private Sub Show Hide Click()

Dim myCellsGuidance As Range
Dim NumRowsGuidance As Long

On Error GoTo ExitSub

NumRowsGuidance = Selection.Tables(1).Rows.Count

With ActiveDocument
Set myCellsGuidance = .Range(Start:=Selection.Tables(1).Rows(2).Range.Start, _
End:=Selection.Tables(1).Rows(NumRowsGuidance).Range.End)
End With

If Selection.Tables(1).Rows(2).Range.Font.Hidden = True _
Then myCellsGuidance.Font.Hidden = False _
Else myCellsGuidance.Font.Hidden = True _

ExitSub:

End Sub

RE: word VBA 2010

Hi Josselin,

Thank you for the code.

I have tested the code in a Word document and your code is working fine. When I tested it, the code removed the first bullet point.

You must have some kind of bug in your document.

If you forward the document I can try to have a look at it.

Kind regards

Jens Bonde
Microsoft Office Specialist Trainer

Tel: 0207 987 3777
Best STL - https://www.stl-training.co.uk
98%+ recommend us

London's leader with UK wide delivery in Microsoft Office training and management training to global brands, FTSE 100, SME's and the public sector

Read more: https://www.stl-training.co.uk/post-34560-formula-shows-quarters.html #ixzz2wE8kbKnu

RE: word VBA 2010

Jens, Thank you for you quick response.
Can you please send me you email address.
Joss

RE: word VBA 2010

Good morning Josselin,

My email address is jens@stl-training.co.uk


Kind regards

Jens Bonde
Microsoft Office Specialist Trainer

Tel: 0207 987 3777
Best STL - https://www.stl-training.co.uk
98%+ recommend us

London's leader with UK wide delivery in Microsoft Office training and management training to global brands, FTSE 100, SME's and the public sector

Read more: https://www.stl-training.co.uk/post-34560-formula-shows-quarters.html #ixzz2wE8kbKnu

RE: word VBA 2010

Thanks Jens, someone from work managed to fix it. It was to do with sequencing of the buttons.
Thank you again fir your support.
Best regards,
Joss

RE: word VBA 2010

Hi Joss,

I am happy to hear that you fixed your problem.

Kind regards

Jens Bonde
Microsoft Office Specialist Trainer

Tel: 0207 987 3777
Best STL - https://www.stl-training.co.uk
98%+ recommend us

London's leader with UK wide delivery in Microsoft Office training and management training to global brands, FTSE 100, SME's and the public sector

Read more: https://www.stl-training.co.uk/post-34560-formula-shows-quarters.html #ixzz2wE8kbKnu

 

Training courses

 

Training information:

Welcome. Please choose your application (eg. Excel) and then post your question.

Our Microsoft Qualified trainers will then respond within 24 hours (working days).

Frequently Asked Questions
What does 'Resolved' mean?

Any suggestions, questions or comments? Please post in the Improve the forum thread.


 

VBA tip:

Use GoTo to Select A Cell With VBA

To select a certain cell on a Worksheet you can use:

Application.Goto Reference:=Range("V300")

or more simply

Range("V300").Select

If, on the other hand, you want the selected cell to be the top/left cell on the screen you use:

Application.Goto Reference:=Range("V300"), Scroll=True

View all VBA hints and tips


Server loaded in 0.09 secs.