Advanced Techniques

The total number of documents currently open


Current version of Word


Current build of Word


StyleAreaWidth ??

Getting the Position of the cursor

x = Selection.Information(wdInformation.wdHorizontalPositionRelativeToPage) 
y = Selection.Information(wdInformation.wdVerticalPositionRelativeToPage)

72pts = 1 inch = 2.54cm
This only works when you are in Page view.
If you are in Normal view it returns the distance from the top margin.
Always set the view to Page view and the magnificationt o 100% before using the Information proeprty to get the cursor position.

Switch to Print Preview

This changes the view to print preview

Application.PrintPreview = True 

Define the size of the window on the screen

With Application 
   .WindowState = wdWindowStateNormal
   .Height = 400
   .Width = 300
End With

Check the File Exists before opening

With Application.FileSearch 
   .FileName = "document.doc"
   .Lookin = "C:\Temp\"
   If .FoundFiles.Count > 1 Then
'file exists so it can be opened
   End If
End Sub

Is there a document currently open ?

If (Documents.Count >= 1) Then 
'a document is currently open
'no document are open
End If

© 2024 Better Solutions Limited. All Rights Reserved. © 2024 Better Solutions Limited TopPrev