|
 |
Word VBA Discuss using VBA to program Word. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the Word VBA section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
|
 |
|
|
 |

August 15th, 2009, 10:42 PM
|
Registered User
|
|
Join Date: Aug 2009
Posts: 7
Thanks: 2
Thanked 0 Times in 0 Posts
|
|
Detemine which part is double clicked
Hi
I am using WindowBeforeDoubleClick event and want to know which part of a document is clicked. The StoryType of Sel(The Selection object) always have the value of 1 so it is impossible to specify which part is double clicked. I provided the main problem that I want to solve in case you want to know it.
What I want to do:
when header and footer is double clicked, a form apears whithout activating header and footer for editing and also the document is not scrolled.
Thanks
|

August 16th, 2009, 10:25 AM
|
Friend of Wrox
|
|
Join Date: Sep 2005
Location: , , .
Posts: 812
Thanks: 1
Thanked 53 Times in 49 Posts
|
|
Can you try this following:
Code:
Sub WhereISelected()
If Selection.Information(wdInHeaderFooter) Then
MsgBox "Within Header"
End If
End Sub
Cheers
Shasur
|

August 16th, 2009, 10:48 PM
|
Registered User
|
|
Join Date: Aug 2009
Posts: 7
Thanks: 2
Thanked 0 Times in 0 Posts
|
|
It still doesn't work
The code is:
Code:
Option Explicit
'reserve memory for an application variable
Private WithEvents wdApp As Word.Application
Private Sub Document_Open()
'assign Word to the application variable
If wdApp Is Nothing Then
Set wdApp = ThisDocument.Application
End If
End Sub
Private Sub wdApp_WindowBeforeDoubleClick(ByVal Sel As Selection, Cancel As Boolean)
MsgBox Sel.Information(wdInHeaderFooter)
Cancel = True
DocumentInfo.Show
End Sub
I added the message box to show the value of Information(wdInHeaderFooter) for Sel. The value is always false no matter which part is double clicked.
It seems the Sel object has no information about which part is double clicked but another question is, why it is in the signiture of this event?
Thanks
|

August 17th, 2009, 09:01 AM
|
Friend of Wrox
|
|
Join Date: Sep 2005
Location: , , .
Posts: 812
Thanks: 1
Thanked 53 Times in 49 Posts
|
|
Hi
Your event works fine in my machine - Windows XP - Word 2003.
Can you give the version where it fails
Cheers
Shasur
|

August 18th, 2009, 03:16 AM
|
Registered User
|
|
Join Date: Aug 2009
Posts: 7
Thanks: 2
Thanked 0 Times in 0 Posts
|
|
Hi
I have the same condition(Windows XP - Word 2003) and I suspected the file I was working on. So I created a new file and pasted the code into it(except DocumentInfo.Show). The problem still exists!
Tell me how can I send you this file for you?
Thanks
|

August 18th, 2009, 07:49 AM
|
Friend of Wrox
|
|
Join Date: Sep 2005
Location: , , .
Posts: 812
Thanks: 1
Thanked 53 Times in 49 Posts
|
|
Hi
Can you send the file to shasur9771 at rediffmail dot com
Cheers
Shasur
|

August 24th, 2009, 01:42 AM
|
Friend of Wrox
|
|
Join Date: Sep 2005
Location: , , .
Posts: 812
Thanks: 1
Thanked 53 Times in 49 Posts
|
|
Got your document
Even if you are 'clicking' the Header actually the cursor is in the body text only.
Can you try clicking the header text using 'Edit --> Header' option
Cheers
Shasur
|
The Following User Says Thank You to Shasur For This Useful Post:
|
|

September 5th, 2009, 07:15 AM
|
Registered User
|
|
Join Date: Aug 2009
Posts: 7
Thanks: 2
Thanked 0 Times in 0 Posts
|
|
Thanks
Hi
sorry for being late.
It seems there is a problem with WindowBeforeDoubleClick. It shows where the cursor is not where double clicked!
I used WindowSelectionChange instead. it has some disadvantages like activating header/footer and also when header/footer is deactivated by code, scrolls the document the the place where the cursor is.
anyway thanks.
|

September 5th, 2009, 10:47 AM
|
Friend of Wrox
|
|
Join Date: Sep 2005
Location: , , .
Posts: 812
Thanks: 1
Thanked 53 Times in 49 Posts
|
|
Glad that it was solved
|
Thread Tools |
Search this Thread |
|
|
Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
 |