How do I use Visual Basic to move to a specific spot on a page

T

TDay

I am working with FrontPage 2002, but can upgrade to 2003 if this would be a
better platform. I repeatedly have data in Excel, Word, and/or Access that I
want to add to an existing page in FrontPage. I can use Visual Basic to open
the page, but I cannot find any examples for the VB code to move from the top
of the page to a specific cell in a table where I would "paste special" the
data.
 
S

Stefan B Rusynko

See
http://msdn.microsoft.com/library/d...orkingWithHTMLProgrammatically.asp?frame=true

--

_____________________________________________
SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
"Warning - Using the F1 Key will not break anything!" (-;
To find the best Newsgroup for FrontPage support see:
http://www.frontpagemvps.com/FrontPageNewsGroups/tabid/53/Default.aspx
_____________________________________________


|I am working with FrontPage 2002, but can upgrade to 2003 if this would be a
| better platform. I repeatedly have data in Excel, Word, and/or Access that I
| want to add to an existing page in FrontPage. I can use Visual Basic to open
| the page, but I cannot find any examples for the VB code to move from the top
| of the page to a specific cell in a table where I would "paste special" the
| data.
 
T

TDay

Your reponse was interesting, but not very helpful. Nothing in that article
tells me how to identify a specific cell, on a row, in a table, on a page so
that I can make that cell the active element so that I can use the commandbar
to delete existing copy and paste new copy. See
http://www.555us.com/555AK/555ak_zipcodes.htm. I have the data in Excel and
have automated the process of updating all zips, but I want to automate the
process of cutting and pasting the four columns of zipcode data. Since each
state page is identical, I need to be able to activate the different cells to
do the cut and paste. If you can provide helpful guidance, it would be
appreciated.
 
T

TDay

I have used the macro from the FPHTMLTableCell help page to locate the cell
as the 1st cell in the 8th row in the first table. Using the variable
objCell, how can I make this cell the activeElement, put it in focus, or
whatever the method is to best?

Thanks,
 
S

Stefan B Rusynko

Accessing Individual Elements explains how to do is using an element's id

--

_____________________________________________
SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
"Warning - Using the F1 Key will not break anything!" (-;
To find the best Newsgroup for FrontPage support see:
http://www.frontpagemvps.com/FrontPageNewsGroups/tabid/53/Default.aspx
_____________________________________________


| Your reponse was interesting, but not very helpful. Nothing in that article
| tells me how to identify a specific cell, on a row, in a table, on a page so
| that I can make that cell the active element so that I can use the commandbar
| to delete existing copy and paste new copy. See
| http://www.555us.com/555AK/555ak_zipcodes.htm. I have the data in Excel and
| have automated the process of updating all zips, but I want to automate the
| process of cutting and pasting the four columns of zipcode data. Since each
| state page is identical, I need to be able to activate the different cells to
| do the cut and paste. If you can provide helpful guidance, it would be
| appreciated.
|
| "Stefan B Rusynko" wrote:
|
| > See
| >
http://msdn.microsoft.com/library/d...orkingWithHTMLProgrammatically.asp?frame=true
| >
| > --
| >
| > _____________________________________________
| > SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
| > "Warning - Using the F1 Key will not break anything!" (-;
| > To find the best Newsgroup for FrontPage support see:
| > http://www.frontpagemvps.com/FrontPageNewsGroups/tabid/53/Default.aspx
| > _____________________________________________
| >
| >
| > |I am working with FrontPage 2002, but can upgrade to 2003 if this would be a
| > | better platform. I repeatedly have data in Excel, Word, and/or Access that I
| > | want to add to an existing page in FrontPage. I can use Visual Basic to open
| > | the page, but I cannot find any examples for the VB code to move from the top
| > | of the page to a specific cell in a table where I would "paste special" the
| > | data.
| >
| >
| >
 
T

TDay

I solved this problem by doing the following:

'I used this code to locate the correct cell
'Dim objTable As FPHTMLTable
'Dim objRow As FPHTMLTableRow
'Dim objCell As FPHTMLTableCell

'Set objTable = ActiveDocument.all.tags("table").Item(0)
'Set objRow = objTable.rows(8)
'Set objCell = objRow.cells(0)
'objCell.bgColor = "#00FF00"

After locating the correct cell, this code moves to the correct cell and I
used the CommandBar to clear the old data.

'This will clear the Preferred Name Column
Dim PreferredName As IHTMLTxtRange
Dim PreferredNameBookmark As String
Set PreferredName = ActiveDocument.body.createTextRange
PreferredName.moveToElementText ActiveDocument.all.tags("td").Item(17)
PreferredNameBookmark = PreferredName.getBookmark
With PreferredName
.moveToBookmark PreferredNameBookmark
.Select
End With
FrontPage.Application.CommandBars("Table"). _
Controls("Select").Controls("Cell").Execute
FrontPage.Application.CommandBars("Edit"). _
Controls("Cut").Execute
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top