Absolute Position A Text Box In Word Macro ??
Hi Guys
Wondering if anyone can tell me if its possible (and how to) absolute position a text box in a word macro....
I have a word document that runs a macro that places a text box on the page containing a barcode. The word document contains text that is editable by the user. However, if the user edits the text, the text box moves as if it is set to position relative to the text. I need the text box to remain in the absolute same spot all the time.
Please, any info on this would be much appreciated.
Nick
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Word Macro To Take Mouse Cursor Position
I have to mark students diagrams and charts etc submitted in MS Word. I have word macros that will create a callout, transparent, in blue, or a large tick in a transparent text box with no border.
I have to drag these from the position on the page where they appear, to where I want them over the students diagram.
Does anyone know how to make a textbox appear at the position of the mouse cursor on the page, using a macro? A working macro that I can then edit to add ticks etc would be very useful.
Even better if it works on Word versions back to 97.
Peter
Absolute Position?
Ok back to my datacontrol thing... now I have the record count total but I want to know what record the user is on when they press forward, back, move first, or last in the data control. I have this
Private Sub Data1_Validate(Action As Integer, Save As Integer)
Dim myStr As String
myStr = "Record " & Data1.Recordset.AbsolutePosition & " of " & Data1.Recordset.RecordCount
info.Caption = myStr
End Sub
but the absoluteposition seems to return random things... such as 3 when the text box really displays record 0 and 2 when its really on record number 4. ... am I using this wrong?
complete code
Code:
Option Explicit
Dim rs As Recordset
Dim tCnt As Integer
Dim myPos As Integer
Private Sub Data1_Validate(Action As Integer, Save As Integer)
Dim myStr As String
myStr = "Record " & Data1.Recordset.AbsolutePosition & " of " & Data1.Recordset.RecordCount
info.Caption = myStr
End Sub
Private Sub Form_Load()
CommonDialog1.ShowOpen
Data1.DatabaseName = CommonDialog1.FileName
'Set rs = .OpenRecordset("AUTHORS")
Data1.RecordSource = "branch"
Set Data1.Recordset = rs
Data1.Refresh ' Open the recordset
Data1.Recordset.MoveLast
Data1.Recordset.MoveFirst
Text1.DataField = "branch_name"
tCnt = 1
End Sub
Absolute Position
Hello...
what the different between selbookmark and absolute position in datagrid...?
i can get the current pointed recordset with that two, can't i ?
how if i do a multiple select ? how absolute position works in multiple select?
thanks,
ganero
.Absolute Position
I have a code errors out telling me I have an invalid key. The code it errors on is as follows:
Do While Not rs.EOF
.Add rs.AbsolutePosition + 1, rs!Site_Number, rs!Site_Number
rs.MoveNext
Loop
(it errors at the .ADD rs line)
I can't find any help on the invalid key error. Anyone have any suggestions?
Thanks
Pat
Absolute Position
I am trying to use rs.absoluteposition to keep incrementing the count on a label, but this always seems to stay at -1. Any ideas?
Thanks!
Erica
Absolute Position In A Query
Hi, using DAO and Access, is there a way to know the exact position of a record in a query ? Like absolute position or something ?
Many Thanks
Absolute Position Of A Record !!!
Friends,
How can I view the number of exact row in a label that is currently showing the data.
Something like this: Record 15 of 75
Help needed please.
Absolute Control Position
ok i want a function 2 find the absolute position of a control on the form.... for example if the control passed in is in 2 pic boxes it will return the twirps to the top left of the form
- i will be doing this kinda thing abit so i need a generic function -
thanks kris
Absolute Control Position?
How can I know the absolute position of a control on a
form, using the upper left corner of the form as 1,1
These controls may be put inside other controls (nested)!
Would anybody help?
Any hint?
Thanks
Absolute Cell Position
Is there any way of obtaining the absolute pixel position of a CELL so that I can use the AddShape position to draw a shape in that cell of equal size and position of that cell?
ie. AddShape(msoShapeOval, Cell.Top, Cell.Left, Cell.Height, Cell.Width)
'Kind of thing'
Many Thanks in advance.
Riyaz
Absolute Position In Data Reports
How can you print out an ordered sequence to number the records in a VB data report? The function control won't go into the detail section, and calculated fields only work if you have other fields to calculate from. It seems so easy in Access (number grouping), but why not in VB? Any ideas?
Record Count And Absolute Position
On my form I'm trying to display the number of recoreds in my Access DB and also the current position I'm at but I'm having no luck. Currently i'm using the below but I keep getting -1 of -1 displayed. Can anyone see what is wrong?
Thanks
Code:
strCn = ConnectString()
sSQL = "SELECT * FROM tblBuy ORDER BY Completed DESC, Date DESC"
Set rsEditBuy = New ADODB.Recordset
rsEditBuy.Open sSQL, strCn, adOpenDynamic, adLockOptimistic
lblTrades.Caption = rsEditBuy.AbsolutePosition & " of " & rsEditBuy.RecordCount
Absolute Character Position In Richtext Box
I am trying to auto generate some text in a richtext box. Characters will have different sizes and be of different widths.
I need a way to line up the tabs inbetween things. Sometimes I need 2 tabs, but most of the time I only need 1 inbetween things (Sorry if this is vauge, I will attach an example if needed).
The only way I can think of accomplishing this is by testing the absolute position of a character from the line above and if absolute position of the current character matches that then leave the tabs how they are, otherwise add a tab until the tabs line up.
I searched through the object browser for a good hour testing all the different properties of the richtext lib, and nothing worked. SelTabs looked promising but it always returns 0 for some reason.
Any ideas?
ADO Record Count And Absolute Position
I finally figured out how display the record count of a table or query as well as the absolute record being focused on, but I am getting eroneus numbers -1 of 26 and when I click on the right or left arrow the counter wont increment (or decrement) unles I click the arrow twice. I put the statement in the form load:
Adodc1.Caption = " " & Adodc1.Recordset.AbsolutePosition & " of " & Adodc1.Recordset.RecordCount
and then I put it under the click sub for the Adodc1 control:
Private Sub Adodc1_WillMove(ByVal adReason As ADODB.EventReasonEnum, adStatus As ADODB.EventStatusEnum, ByVal pRecordset As ADODB.Recordset)
Adodc1.Caption = " " & Adodc1.Recordset.AbsolutePosition & " of " & Adodc1.Recordset.RecordCount
End Sub
Any suggestions on how I can get the proper results? Also when a query is run and produces no results, I would like the "counter" to display 0 of 0 instead of -1 of 0 and the control seems to be shaded like Enabled = False. DAVE
Visio - How To Move Shape To Absolute Position?
Hi,
Thanks for taking the time to look at my post.
I would like to move a shape object to an absolute location of my choice, e.g. I would like to know how to move a shape object to position (100, 100).
The selection object's move method only allows the selection to be moved relative to where it's original position was.
here is the code:
VB Code:
Sub start() Dim aShape As ShapeDim aSelection As Selection Set aShape = Documents(1).Pages(1).Shapes(1) ActiveWindow.Select aShape, visSelect Set aSelection = ActiveWindow.SelectionaSelection.Move 2, 2 'i want to move to an absolute location, not just 2 up and 2 right like this line doesEnd Sub
Thanks for your time
<>GT<>
Finding All Links Absolute Position X,Y Relatively To The Screen In VB6 WebBrowser
Finding all links absolute position X,Y relatively to the screen in VB6 WebBrowser
There is a Visual Basic 6 application with WebBrowser in it.
This application is about statistical information on what html tags were loaded, where they are being located - it's position X,Y
For example I want to find Document.getelementsbytagname("a") link and anchor position on the screen, how do I do it?
There is example in JS, that I could inject into webpage by scriptcontrol but could I do in in VB6 itself?
function getElementPosition(elemId)
{
var elem = document.getElementById(elemId);
var w = elem.offsetWidth;
var h = elem.offsetHeight;
var l = 0;
var t = 0;
while (elem)
{
l += elem.offsetLeft;
t += elem.offsetTop;
elem = elem.offsetParent;
}
return {"left":l, "top":t, "width": w, "height":h};
}
Trying by vb6 in webbrowser
Dim WithEvents doc As HTMLDocument
Dim elem As IHTMLElement
Set doc = ie.document
For x = 0 To doc.getElementsByTagName("a").length - 1
Set elem = doc.getElementsByTagName("a")(x)
I want convert this nonsense
'"-PParent=" & elem.offsetParent.offsetParent.tagName & "=" & elem.offsetParent.offsetParent.id & _
'"-3Parent=" & elem.offsetParent.offsetParent.offsetParent.tagName & _
'"-4Parent=" & elem.offsetParent.offsetParent.offsetParent.offsetParent.tagName & _
'"-4Parent=" & elem.offsetParent.offsetParent.offsetParent.offsetParent.id
To while loop, but I can't figure it out how
While (TypeOf elem Is IHTMLElement)
parentall = "-Parent Tag=" & elem.offsetParent.tagName & _
elem.id & ",l=" & elem.offsetLeft & ";t=" & elem.offsetTop & _
Set elem = elem.offsetParent
Wend
Next x
Finding All Links Absolute Position X,Y Relatively To The Screen In VB6 WebBrowser
Finding all links absolute position X,Y relatively to the screen in VB6 WebBrowser
There is a Visual Basic 6 application with WebBrowser in it.
This application is about statistical information on what html tags were loaded, where they are being located - it's position X,Y
For example I want to find Document.getelementsbytagname("a") link and anchor position on the screen, how do I do it?
There is example in JS, that I could inject into webpage by scriptcontrol but could I do in in VB6 itself?
function getElementPosition(elemId)
{
var elem = document.getElementById(elemId);
var w = elem.offsetWidth;
var h = elem.offsetHeight;
var l = 0;
var t = 0;
while (elem)
{
l += elem.offsetLeft;
t += elem.offsetTop;
elem = elem.offsetParent;
}
return {"left":l, "top":t, "width": w, "height":h};
}
Trying by vb6 in webbrowser
Dim WithEvents doc As HTMLDocument
Dim elem As IHTMLElement
Set doc = ie.document
For x = 0 To doc.getElementsByTagName("a").length - 1
Set elem = doc.getElementsByTagName("a")(x)
I want convert this nonsense
'"-PParent=" & elem.offsetParent.offsetParent.tagName & "=" & elem.offsetParent.offsetParent.id & _
'"-3Parent=" & elem.offsetParent.offsetParent.offsetParent.tagName & _
'"-4Parent=" & elem.offsetParent.offsetParent.offsetParent.offsetParent.tagName & _
'"-4Parent=" & elem.offsetParent.offsetParent.offsetParent.offsetParent.id
To while loop, but I can't figure it out how
While (TypeOf elem Is IHTMLElement)
parentall = "-Parent Tag=" & elem.offsetParent.tagName & _
elem.id & ",l=" & elem.offsetLeft & ";t=" & elem.offsetTop & _
Set elem = elem.offsetParent
Wend
Next x
Server Side Cursor Recordset Absolute Position
I apologize in advance for this one since I have seen a solution for this some time ago, but cannot seem to turn it up in a search.
I am using a server side cursor (This will be an advantage for several reasons, so I will not want to change this).
I only need to determine the recordset absolute position and the recordset count so I can display "Record 1 of 25" or whatever.
I do a move last then a move first, but still receive the values of -1 for both absolute position and count.
I am using VB6 with SQL Server 7 ADO connection
Terry (cyberbiker)
Finding All Links Absolute Position X,Y Relatively To The Screen In VB6 WebBrowser
Finding all links absolute position X,Y relatively to the screen in VB6 WebBrowser
There is a Visual Basic 6 application with WebBrowser in it.
This application is about statistical information on what html tags were loaded, where they are being located - it's position X,Y
For example I want to find Document.getelementsbytagname("a") link and anchor position on the screen, how do I do it?
There is example in JS, that I could inject into webpage by scriptcontrol but could I do in in VB6 itself?
function getElementPosition(elemId)
{
var elem = document.getElementById(elemId);
var w = elem.offsetWidth;
var h = elem.offsetHeight;
var l = 0;
var t = 0;
while (elem)
{
l += elem.offsetLeft;
t += elem.offsetTop;
elem = elem.offsetParent;
}
return {"left":l, "top":t, "width": w, "height":h};
}
Trying by vb6 in webbrowser
Dim WithEvents doc As HTMLDocument
Dim elem As IHTMLElement
Set doc = ie.document
For x = 0 To doc.getElementsByTagName("a").length - 1
Set elem = doc.getElementsByTagName("a")(x)
I want convert this nonsense
'"-PParent=" & elem.offsetParent.offsetParent.tagName & "=" & elem.offsetParent.offsetParent.id & _
'"-3Parent=" & elem.offsetParent.offsetParent.offsetParent.tagName & _
'"-4Parent=" & elem.offsetParent.offsetParent.offsetParent.offsetParent.tagName & _
'"-4Parent=" & elem.offsetParent.offsetParent.offsetParent.offsetParent.id
To while loop, but I can't figure it out how
While (TypeOf elem Is IHTMLElement)
parentall = "-Parent Tag=" & elem.offsetParent.tagName & _
elem.id & ",l=" & elem.offsetLeft & ";t=" & elem.offsetTop & _
Set elem = elem.offsetParent
Wend
Next x
VBA Excel Absolute Addressing In The VB Macro
I have an excel spreadsheet of parts and have built a macro to subtract certain quantities from various parts depending on user input. My only unresolved concern is that the user of this spreadsheet may want to add another part to the list by inserting a row in the middle of this list. When this happens, all of the quantities below the point of insertion are shifted down a row. If the macro is run after this insertion, it subtracts quantities from the wrong cells because it is still addressing the cell in which the quantity existed before the insertion. For example, if part A has a quantity of 50 in cell C6 and the user inserts a row above row 6, then part A's quantity of 50 is now in cell C7. When the macro is run, it still subtracts part A's X number of parts from C6 instead of C7. I just need to know if it is possible to tell the macro that another row has been added so that it can adjust accordingly. Any suggestions?
Open Word, Insert Text Then Run Macro
I use the following code to open MS Word and insert the contents of a Listbox. What I'm looking is that once the contents of the listlox are inserted can I run a macro that I have created in Word called 'AutomateReport'?
Code:
Private Sub CmdNext_Click()
Dim n As Integer
Dim TextToSave As String
Dim fNum As Integer
Dim FileName As String
Dim DocToOpen As String
Dim DocPath As String
Dim MyReport As Object
If LstSelected.ListCount <> 0 Then
DocPath = App.Path
DocToOpen = DocPath & "Template.doc"
For n = 0 To LstSelected.ListCount - 1
TextToSave = TextToSave & LstSelected.List(n)
'add delimiter, except on last item
If n < LstSelected.ListCount - 1 Then TextToSave = TextToSave & vbLf
Next n
Set MyReport = CreateObject("Word.Basic")
MyReport.FileOpen DocToOpen
With MyReport
.EditGoto "StartDocument"
.Insert TextToSave
End With
Dim objWord As Word.Application
Set objWord = New Word.Application
objWord.Visible = True
objWord.Documents.Open DocToOpen, , , True
Else
MsgBox "No items in list", vbCritical, "Warning"
End If
End Sub
Unhide Hidden Text By Macro In Word-97 (secured Template ).
In a template hidden text is used. Before this text I inserted a checkbox.
I would like to unhide the hidden text when I click on the checkbox.
I made a macro which unhides the hidden text.
When I change the properties of the checkbox with the command to run the defined macro it doesn't react.
Of course I secured the section otherwise my form doesn't work.
Since the upperside method doesn't work properly I tried to insert the text from a separate document.
I also tried this by using a checkbox in the main document.
Again I defined a macro which inserts the text and places it below the checkbox.
Unfortunately this doesn't function either.
Is there someone who has a idea for solving this problem.
Word Macro Insert File/ Append Table Macro Issue.
Hello,
I was wondering if someone could help me with this problem...
When I use the following code to insert a table (from an external file), the table that is inserted does not append to the table in first document (which is what I want it to do)...
Sub Macro1()
Selection.Collapse Direction:=wdCollapseEnd
Selection.InsertFile FileName:="m:cat.DOC", Link:=True
End Sub
Would anyone know how I can make the contents of this file append to the table in the first document?
Thanks so much in advance,
Anne
Absolute Beginner Needs Help With Searching Text Files
Hello all,
Hope this is the correct group for this question.
I couldn't find a vb beginners group.
I am getting overwhelmed and need some help.
I did this very easily in a batch file (only three lines), but DOS is too
limited and the use of the batch is presenting other problems (file is
compressed so I get garbage characters in the output file which I can't
edit).
I also wanted some other functionality added and decided to try VB6.
Problem - (Totally lost and frustrated)
How do I search all files with a given extension (ex. *.zip) for text inside
those files and output those lines (strings) to a text file?
I need to be able to use wildcards, so from what I read the use of the File
System Object is not going to help me.
The files are compressed (don't know if that matters).
The text lines (strings) in the files I am looking for would be something
like *.bspPK(trailing garbage characters)
Any help will be much appreciated.
Thank you
Word Macro Editor Opens When I Misspell A Macro Name
I'm using Word 2000, and pressing Alt+F8 to access macros - just text strings - and here's the trouble:
I'm trying to make it possible for everyone here to use Word macros from the server. I've put a file out there called Macros.dot and it works great. Every machine in the building can see it and use it. Trouble is, if a user misspells a macro name the macro editor opens by default. It doesn't realize the user has misspelled something and thinks the user wants to write a new macro under the "new" name. User can click the X to close the editor, of course, but has now created a blank macro with a name very similar to a real macro. This will drive people (especially the less tech savvy) nuts, and clog up the file Macros.dot with garbage.
Is there a way to disable the macro editor from opening if an incorrect (nonexistent) macro name is typed? A check box somewhere, perhaps? I've tried but can't seem to find it, if it's there.
Thanks
Openning Excel And Running Macro From Word - Macro
Ok - I have a DB which I export to Excel, I then run a macro to "Groom The Data". I then run word and run a Macro (MailMerge to print labels) which retrieves data from the excel spreadsheet groomed above. Everything is working fine, despite my novice knowledge of VB, but I would like to do this in a single click.
I use a command line shortcut to Launch word and automatically have it run the macro, but I still have to Launch Excel and manually run its macro first.
I did not find a command line switch to make excel launch and run a macro. Is there any way I can Lauch Word have its Macro link to excel, then launch and run the excel macros before performing the macro I have set up in word (mailmerge)
In Other Words I have working macros in Word and Excel, I want the Word Macro to force the Excel macro to run before completing the rest of its duties.
Thanks
WW
Word 200 Vba Macro Help - Enable Track Changes In A Macro. Thanks
I was able to find a macro which takes an already mail merged document, and saves each each document as a separate file. The document's filename is taken from the already merged document. The script works. It's in red. See below.
The problem is I need to enable the track changes option.I recorded the following macro. It's in blue.
With ActiveDocument
.TrackRevisions = True
.PrintRevisions = True
.ShowRevisions = True
End With
End Sub
I tried to incorporate this code(blue) into the code (red) below. I added it between ActiveDocument.Sections.First.Range.Cut and Documents.Add but it didn't work.
ActiveDocument.Sections.First.Range.Cut
ActiveDocument.TrackRevisions = True
ActiveDocument.PrintRevisions = True
ActiveDocument.ShowRevisions = True
Documents.Add
It turned on track changes but it didn't create each new document. What am I doing wrong?
Desperately Seeking help!!
Script works perfectly.
Sub SplitMergeLetter()
' splitter Macro
' Macro created 16-08-98 by Doug Robbins to save each letter created by a
' mailmerge as a separate file.
'
Selection.EndKey Unit:=wdStory
Letters = Selection.Information(wdActiveEndSectionNumber)
Selection.HomeKey Unit:=wdStory
Counter = 1
While Counter < Letters
Application.ScreenUpdating = False
Selection.HomeKey Unit:=wdStory
Selection.MoveRight Unit:=wdWord, Count:=1, Extend:=wdExtend
sName = Selection
'set path below
sPath = "C:MERGELETTERS"
Docname = sPath & sName
ActiveDocument.Sections.First.Range.Cut
Documents.Add
With Selection
.Paste
.EndKey Unit:=wdStory
.MoveLeft Unit:=wdCharacter, Count:=1
.Delete Unit:=wdCharacter, Count:=1
End With
ActiveDocument.SaveAs FileName:=Docname, _
FileFormat:=wdFormatDocument
ActiveWindow.Close
Counter = Counter + 1
Application.ScreenUpdating = True
Wend
End Sub
Word VBA / Macro Problem With Print && Browser (Word 2000)
I am trying to use a macro inside the AutoOpen() event of a Word doc so that when the Word doc is opened inside IE, it will print the Word doc then close both the Word doc and the IE window. For some reason, VBA loses its reference to the doc object and IE Application object after the PrintOut line is executed. I have tried things like:
Sub AutoOpen()
MyWord.Visible = False
MyWord.ActiveDocument.PrintOut
MyWord.ActiveDocument.Close False
End Sub
or:
Sub AutoOpen()
With ActiveDocument
.PrintOut Background:=False
.Close savechanges:=False
.Parent.Quit
End With
End Sub
or:
Sub AutoOpen()
Dim MyWord As Object
Set MyWord = GetObject(, "Word.Application")
Dim IE As Object
Dim IEDoc As Object
Set IE = GetObject(, "InternetExplorer.Application")
Set IEDoc = MyWord.ActiveDocument
IEDoc.PrintOut
IEDoc.Close
IE.Quit
End Sub
But whatever I try, the Word doc prints, then throws a 4605 error about the method or property not being available because the document is in another app. Any ideas?
Thanks,
Chris
MsWord - Word Position
Hi,
In a MsWord document, you have at the bottom of it in the "status" bar, page number, section number, page 1/1, at x.y inch, Line X Column Y
I you like to know which LINE and COLUMN my cursor is in when I select a Word.
All done programmatically... Anybody knows how?
Get Word's Cursor Position
Hi,
I have a form that opens on top of a doc so the user can perform a search. The form is rather minimal, but it still gets in the way sometimes and covers the search hit (selected text in the doc).
I want the form to move out of the user's view. Since the search hit is selected, I could use the insertion point's position on the screen as reference, but I don't know how to do that in VBA or using an API call.
Any help would be highly appreciated.
Regards,
Guillermo
Position A Reserved Word?
Someone please tell me that they knew the word Position was a reserved word in Access or VB... I just spent several hours trying to setup a Dataset in vb.net to a combobox and had the fieldname Position in the database and was getting all kinds of weird errors. Anyways if you didn't know now u know.
Word Page Position
How can I determine the page number where my cursor is positioned?
Help is much appreciated!
How To Find The Start And End Position Of A Word
I am now writing a VB program for Word. I want to write a program that, a user don't need to highlight the whole word and rightclick. The user just need to click any position between a word, then rightclick, then the program can know the start and end position of the word.
Now I was using the following code to do so:
Selection.MoveLeft unit:=wdWord, count:=1
Selection.MoveRight unit:=wdWord, count:=1, Extend:=wdExtend
startPos = Selection.Range.Start
endPos = Selection.Range.End
However, the above code will highlight the whole word. The cursor position has been changed. I don't want ithappen. I just want the program determine the position without highlighting the word and the cursor position is unchanged. How can i do so?
Thx a lot!
Position Shape In Word Document
hi,
I am able to overlap jpg picture in word document. Now I am trying to position it over the selected text. How can I do that?
I am using following code and able to position but its not working perfectly.
I am using information(wdHorizontalPositionRelativeToTextBoundary) to get insertion location.
Code:
Dim app As Object
Dim myDocument As Document
Private Sub Command1_Click()
runWord
SelectionFind text1.Text
insertImage
End Sub
Sub runWord()
Set app = CreateObject("Word.Application")
Set myDocument = Documents.Open(FileName:="c:data.doc")
app.Visible = True
myDocument.Paragraphs.LineSpacing = 24
End Sub
Sub insertImage()
setProperty
End Sub
Sub setProperty()
Dim imageName As String
Dim offsetY, offsetX, offsetWidth, offsetHeight As Integer
imageName = "c:circle.jpg"
myDocument.Shapes.AddPicture FileName:=imageName
ActiveDocument.Shapes(1).WrapFormat.Type = wdWrapNone
ActiveDocument.Shapes(1).ZOrder msoSendToBack
ActiveDocument.Shapes(1).ZOrder msoSendBehindText
SelectionFind (mainfrm.text1.Text)
ActiveDocument.ActiveWindow.View.Type = wdPrintView
ScaleMode = 3
x = Selection.Information(wdHorizontalPositionRelativeToTextBoundary)
y = Selection.Information(wdVerticalPositionRelativeToTextBoundary)
ActiveDocument.Shapes(1).Width = TextWidth(Selection.Text) + 4
ActiveDocument.Shapes(1).Left = x + offsetX
ActiveDocument.Shapes(1).Top = y + offsetY
End Sub
Sub SelectionFind(strFind As String)
Dim temp As String
With app.Selection.Find
.Text = strFind
If .Execute = True Then
MsgBox "Text found.", vbOKOnly
End If
End With
End Sub
I am attaching output file. my objective is to take selected text inside circle picture. When I select bigger or smaller text and that will difference in allignment. How can I maintain allignment regardless of text length.
I only want to insert picture over selected text. but search method search all document so if there are some other matches that will make improper operation.. How can I do that?
Thanks
Help! How Can I Position A Form On Top Of A Word Document?
I have a Word document that pops up a userform when certain fields on the Word document are entered. Is there any way to figure out the position of the control on the form so I can position my vb form on top of the control on the Word document, taking into account screen resolution, zooming, scrolling, toolbars, etc...?
I've worked it out except for vertical scrolling and zooming, but it seems like a convaluted way of doing it. Is there an easy way to do this?
Getting Character Position Of String In Word Document
Hi,
The motivation for my question is this:
I intend to introduce tags into a Word document and use them for formatting.
For example, somewhere in the document The following string is inserted:
<b>My bold string</b>
I need to find this string programatically and format it, removing the tags.
I thought I could do it using the Find object and getting the character positions of the tags. I couldn't figure out how to do it. I was dismayed to find out the Find object does not provide the Start and End character positions.
Any ideas?
Thanks, Ron
Find Curser Position On Word Document
Hi
Is there any command that will show me an integer/long value for the curser or scroll bar position in a word document
so that when i find a word in the document i can tell if it before or after a position stored in a variable?
VB MS Word Template. Cursor Position On Form?
I've created a form to simplify data input (just less clicking all over the place) THe problem is once the form is completed, the cursor/Caret isn't where I want it to be.
How do I get the cursor/caret to be in a specific place in a document once the Form has been completed and the info automatically put into the document? (I've used bookmarks to insert my info into this ms word document).?
Presently the cursor/caret shows up at the end of the document (Where the final Return carrage is). I want it to be at the beginning of the document though.
Any advice?
Mouse/cursor Position In Word Document
I'm using Word automation in my VB6 application.
*What i want to do:
-I have several textbox shapes. When i click in one (Postalcode) i am showing a button (is a small vb form, so the word textboxshape keeps focus).
This allready works fine. Only i can't get the form/button to position corectly.
I want it placed right to the active TextBoxshape. The problem is getting the correct screen x y for this to place my form. I can't use api GetCursorPos because this follows the mousecursor and is not reliable. Getting the textbox x y i can do
Code:set Tbox = Appword.selection.ShapeRange
pt.x = scalex( Tbox.left, vbpoints,vbtwips)
pt.y = scaley(tbox.top,vbpoints, vbtwips)
frmPostalCode.show vbmodeless
frmPostalCode.Move pt.x, pt.y
'I probable should allso add the Word window left and top.
pt.x = scalex( Tbox.left + AppWord.left, vbpoints,vbtwips)
pt.y = scaley(tbox.top+AppWord.Top,vbpoints, vbtwips)
Only these x y values aren't correct (to small) probably caused by the word document's position having gray area around , i should then proably get the coordinates of the left top position of the white document leftup corner.
*An alternative solution would be to create a button/picture in word doc itself.
Only more difficult to keep the focus on the active textboxshape. Allso a don't wonna use a command button (try to avoid using the Word build in VBA designer). The above solution with vbform seems better to me.
The result wil be this. Word document is open. User clicks on postal textbox shape, a arrowbutton amerges. User clicks arrowbutton and a dbgrid form popsup and user browses to the destination corresponding and pushes the arrowbutton again, which now fills in the Locationfield next to the postalcodefield/textboxshape.
Edited by - lvermeersch on 11/21/2005 11:07:13 PM
Determining Vertical Position In A Word Document Using Vba
Hello.
I'm wondering how I would determine, using VBA, how far down a page from the top an element on a word document is located?
Here's my situation:
I have a document with three tables. The last (bottom) table is static (always the same size). The top table is fairly static, but the row heights do change slightly depending upon information entered in a userform (which then populates the table).
The middle table is the one I'm interested in. I use a userform to have new rows added to the second table and populate the new row.
I want to limit the size of this middle table so that it does not allow a second page to be created. Currently, I'm using height rule to add the row heights of each row in this table, and then I check to see if the total height is greater than a certain number.
Obviously, this method has some drawbacks. If the top table gets unusually large (which it may in rare occasions), then the middle table may still be to large and thus bump to a second page. Also, in my row height check, I make a big assumption that if a new row was added, it would have the same row height as the last current row in the table. And, the 'certain number' I compare to is a set number, while in reality the total avaialble height of the table will depend on the total height of the first table. I suppose I could add the total height of both tables, and then compare THAT to a 'certain number', but there must be a much simpler way to go about it!
I'd like instead to be able to check the table height by comparing the absolute position of the bottom of this table (from the top of the document) against a predetermined maximum distance from the top.
All help or comments are appreciated!
Thanks,
Corey Dale
Open Text File, Select Text At Position
vb gurus of the world
I'm relatively comfortable with the Shell function and manipulating text in a text file. I'm finding it surprisingly difficult to place the caret and select text, however. Has anyone been here before? If so a few hints would be great!
Bas
Control Position And Size Of Picture Inserted Into WORD
Hi guys...heres another problem I have...I have a code which sends values in textboxes and also pictures to WORD. This is the code:
Code:
Private Sub Command1_Click()
On Error GoTo WN_Err
Dim objWord As New Word.Application, objDocument As Word.Document
Dim strBK As String, strValue As String
Dim strWordTemplate As String
Dim i As Integer, intCount As Integer
strWordTemplate = "C:DemoTemplate.dot"
With objWord
.Documents.Add Template:=strWordTemplate, NewTemplate:=False
'Add the hello part
.Selection.GoTo What:=wdGoToBookmark, Name:="bkmHello"
.Selection.TypeText Text:=Me!Text1.Text
.Selection.InlineShapes.AddPicture "C:file.jpg", False, True
End With
WN_Exit:
Set objWord = Nothing
Exit Sub
WN_Err:
MsgBox Err.Number & ": " & Err.Description, vbExclamation, "Word Error"
Resume WN_Exit
End Sub
The problem is what code should I add to control the size of the picture and the position of it. For strings I used bookmarks to state the position of the strings added. What should I do for pictures?
As usual any help will be appreciated...
How Can I Find The Position Of Bookmark In A Word 2000 Document?
I've been struggling with a particular report for a while now, and hope that the VB community can help me with this problem. I want to find the position of a bookmark or form field in a word document. (I'll explain my situation below)
I have attached a jpg with an example of what I am trying to do.
The report has a header always at the top of the first page. (I can't use a header though because I have several form fields in it, but thats no biggie). Usually, the header + body + footer will fit on a single page and nothing goes wrong. However, when the body causes the footer to go to the next page, I am required to show this footer only on the bottom of the last page of the report (which probably will never be longer than 2 pages, but I don't want to assume that).
Initially I thought this could be done with tables and continuous sections in Word, but I haven't had any luck.
Why do I want to find the position of a form field or bookmark? At the beginning and end of the footer section, I've placed textboxes. (txtBegin and txtEnd). I think that I can add a carriage return until I determine these boxes are no longer on the same page, and then I can delete the last carriage return and this footer will sit perfectly at the bottom of the page.
These are my thoughts for a solution. I'm hoping that someone can help me find a way to determine the line or page the bookmark is located on, but I would be welcome to any suggestions at this point.
Thanks for any help the vb community can provide.
Tyler Dueck
dueck@hadmacker.com
|