Word - Loop Through Each Page In Document And Copy Page With Page Format
Here's what i'm trying to accomplish
1 - Start at first page and get page format (portrait/landscape)
2 - Copy page and paste it into a new word document with original format
repeat these steps until all pages have been copied
I need the condition where a document has both portrait and landscape pages.
Anyhelp would be appreciated
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
How Can I Select ONE Page Of A Multi-page Word OLE Document?
Hello,
I have the following code that works just fine as long as I have a Single-page word document loaded. However, I need to Select EACH page individually and rasterize into a TIF image. You will note that I am able to Find Text and Select the Entire Line. I can also Select the ENTIRE document using the "OLE1.object.Content.Select" method. But I just can't seem to figure out how to select a Single Page!!!
Once I use the ".Copy" method I AM able to "Paste" it into my Imaging Viewer (Pegasus ImagXpress) object. It is critical that I save these pages individually. Here is the code I'm using for this:
Code:
Private Sub Command3_Click()
OLE1.DisplayType = 0 ' Display object in the control
OLE1.CreateEmbed "C:Merged.doc", "Word.Document"
OLE1.DoVerb vbOLEActivateGetFocus
OLE1.SizeMode = vbOLESizeStretch
'Find Text
With Selection.Find
.ClearFormatting
.MatchWholeWord = True
.MatchCase = False
.Forward = True
For i = 1 To 10
.Execute FindText:="Client Account #:"
DoEvents
If .Found Then
With Selection
.EndOf unit:=wdLine, Extend:=wdSelStartActive
' Copy the selection to the Clipboard
.Copy
' Paste the entire selection into the Text1 form field
Text1.Text = Trim(Clipboard.GetText)
' Break out the Account # and paste it into the Text2 field
Text2.Text = Right(Text1.Text, Len(Text1.Text) - InStrRev(Text1.Text, ":"))
End With
End If
DoEvents
'Select the entire document
OLE1.object.Content.Select
With Selection
.StartOf unit:=wdGoToAbsolute extend:=wdline
'Copy selection to clipboard
.CopyAsPicture
End With
DoEvents
Form2.ImagXpress1.Paste
MsgBox Form2.ImagXpress1.ImagError ' Shows Zero if No Error
Form2.ImagXpress1.Refresh
Form2.Show
DoEvents
'Goto next page
Selection.GoTo What:=wdGoToPage, Which:=wdGoToNext
Next
End With
' OLE1.Close
End Sub
Thanks,
Jacob
Edited by - JacobRusso on 11/18/2003 5:05:10 PM
Open A Copy Of A Word Document In Html Page
Hallo everyone,
I want to open a copy of a document clicking a link in a html page.
I try with ActivexObject:
var wd = new ActiveXObject("Word.Application")
wd.Documents.Open("file:example.doc")
But the problem is that in this way it always the original copy to be open and not a temp file.
Could anyone help me?
Thank you
Adperi
Page Number & Page Count In Word (automation)
I think I've searched quite everywhere for this, and I haven't found any information at all. I want to be able to write (in VB) the page number and page count in the footer of a Word document, using Automation. I can alreay write the page number OR the page count, but not both, and I can' t add text to the footer.
I want something like "Page 2 of 5" in the footer of every page of the Word document, but I can't seem to get the hang of it, and I've run out of options. Thanks to anyone taking the time to read this post, and many thanks to anyone with a possible solution!
Raggart
Displayed Page Number Vs. Word Page Num
I'm trying to get the page num which appears in the footer using the {PAGE} field into a VBA variable. I've tried using:
Selection.Information(wdActiveEndPageNumber)
but that returns the actual Word page number (ex: 5), rather than the {PAGE} num (ex: 2-1)
Any assistance is appreciated.
01000111
Printer Change Page Orientation From Page To Page
I'm running VB 5. Is it possible to change the page orientation from one page to another.
portion of code:
If page_orientation(gridno) = 0 Then
Printer.Orientation = vbPRORPortrait
Else
Printer.Orientation = vbPRORLandscape
End If
If I use "Printer.EndDoc" before the above code, the program works fine. Each page is a separate 'print-job' with the orientation that I want. A problem arises when I want to print to a .PDF printer: each page is saved as a separate PDF because they're all separate 'print jobs'.
If I substitute "Printer.EndDoc" with "Printer.NewPage", I get the error "orientation property cannot be set within a page". Is there any way to get around this?
Err: 'Page Header Plus Page Footer Is Too Large For The Page' With CR9.0
Dear All
I have a trouble making a report using Crystal Report 9.0. I am working on a project which is developed in vb 6.0. What it actually does is, pick some details from the DB (Access 2000) and shows it on the CR 9.0. I've made a TTX File for the same.
But as I run the report it gives an error msg which says Err: 'Page Header plus Page Footer is too large for the page'
To Mention : I am using the custome page size i.e. 6" x 8"..
Can any body help me plz...
Regards,
K****ij
Err: Page Header Plus Page Footer Is Too Large For The Page Using CR9.0
Dear All
I have a trouble making a report using Crystal Report 9.0. I am working on a project which is developed in vb 6.0. What it actually does is, pick some details from the DB (Access 2000) and shows it on the CR 9.0. I've made a TTX File for the same.
But as I run the report it gives an error msg which says Err: 'Page Header plus Page Footer is too large for the page'
To Mention : I am using the custome page size i.e. 6" x 8"..
Can any body help me plz...
Regards,
Kshitij
Adding New Page To Word Document.
Hi everyone,
How do you add new page (not new document) into the word document?
For example, in the ASP page, i have 5 tables dynamically generated.
Then i invoke a client side script, each table in the HTML page will be added to a new page of the word document.
How should I go about doing that?
Please advise. Thanks
Deleting A Page In A Word Document
Ive set up a word object using the word.application obect and have a number of table spread across several pages. What i'd like to do is delete one of the pages or not display it under certain circumstances.
I'd of thought there would be something along the lines of:
newdoc.activedocument.page(index).delete
but there isnt. Any ideas on how you can delete pages?
Trying To Put In A Page Break In A Word Document
Hey guys,
My VB6 code opens a WOrd Document and generates a table in it. What I need to know is that after a certain number of cells I want to skip to the next page even the though the page has not ended. Is there way I can put in a page break after a certain number of cells have been filled up in the table. Also is there way I can tell if the page is about to end i.e. only one line is left on the page or something along those lines.
Thanks, any kind of help will be appreciated.
moy021
Word - Read Page By Page
Hi guys,
I'm creating macro to send Word document as Fax to an API. From the Word template, I need to pick up three fields (Fax No, Sender Name & Subject) from each page and send the particular page as Fax. Then I need to jump to next page and select the next 3 fields and send that page as Fax.
I know how to search the fields in the document by using Code:Selection.Find.* command. But how do I read Page by Page? Currently, it always goes back to the first page when I do the search.
Please help.
P.S. The document is created by using Mail Merge and may consists hundreds of pages.
Format A Page Of Word
Actually, I want to format paragraphs of a word document. My objective is that:
I want to make an application in VB which opens an word document(browsing option)
and takes from user the formatting options as for example, font=Arial. That is whole document will be formatted with Arial font.
How To Add Shapes Past 1st Page Of Word Document?
I am automating MS-Word 2000 with VB6 (SP5) using the Word 9.0 object library. I can successfully add text to create a multiple page document. However, I can only add images to page 1. How can I set the image anchor to any page in the active document?
Let's say my document already contains 3 pages, and I want to add the same image (at the same location) to each of the pages.
If one was to loop through the following, i.e.:
ShapeIndex = ShapeIndex + 1
oDoc.Shapes.AddPicture "c:Test.bmp"
oDoc.Shapes(ShapeIndex).Top = InchesToPoints(0.7)
oDoc.Shapes(ShapeIndex).Left = InchesToPoints(1.4)
three images (on top of each other) would be added to page 1, which is not the desired result.
The Microsoft Word speaks of an 'anchor' argument as part of the .AddPicture method, but there is no example on how to implement this option.
Can anyone help me out?
Thanks in advance.
Word Document Is Withen Page Margins
I am using automation to print word files. However, some file are outside the page margins. When thoes file are printed a message box appears that it is ouside the page margin.
I discovered that if the Word application is hidden
Code:
wApp.DisplayAlerts = wdAlertsNone
doesn't work. Only when the Word document is visible it seems to disable all messages. Unless a Word doc is outside the page margins, I want Word to be hidden. How do I test to see if the Word Document is outside the Page Margins?
Thank You
Inserting Page Break In Word Document From VB
Hii All,
I am having a problem in inserting page break into a word document from vb.basically i am trying to create a report in word from vb.
First i am putting my code:
set rs1="select * from tablename"
if not rs1.eof then
Set wrdapp = New Word.Application
Set wrddoc = wrdapp.Documents.Add
wrddoc.Select
Set wrdSelection = wrdapp.Selection
do while not rs1.eof
//my aim is to put details of each record in one page
If wrdapp.ActiveWindow.ActivePane.View.Type = wdNormalView Or wrdapp.ActiveWindow. _
ActivePane.View.Type = wdOutlineView Then
wrdapp.ActiveWindow.ActivePane.View.Type = wdPrintView
End If
wrdapp.ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
wrdapp.ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
///picture is inserted
wrdapp.Selection.InlineShapes.AddPicture FileName:="C:cesclogo.jpg", LinkToFile:=False, SaveWithDocument:=True
wrdapp.Selection.TypeText rs1.fields(0).......fields(n)
wrdapp.Selection.InsertBreak Type:=wdPageBreak
//with the above code i am getting my desired output
//ie the picture and the field values are getting printed properly in //each new page.
//Now the problem is i want to put the recordset field values in
//tables for this i have added the followng code.
wrdapp.Selection.Tables.Add wrdapp.Selection.Range, NumRows:=1, NumColumns:=3
With wrdapp.Selection.Tables(1)
.Cell(1, 1).Range.InsertAfter "STOCK REVIEW REPORT"
.Cell(1, 2).Range.InsertAfter "A.Bhowmick R.K Ghosh"
.Cell(1, 3).Range.InsertAfter rs1.fields(0) etc. etc.
End With
//ie i am not going to write this portion of code
// wrdapp.Selection.TypeText rs1.fields(0).......fields(n)
//instead i want to display contents of recordset in word table.
//now by inserting a table whatz happening is that if my recordset returns 3 rows a picture is getting inserted at the top of each page but all 3 tables along with their contents is appearing in the last page .i want each table to appear in each page along with the image.i hav no idea whats happing here.
rs1.movenext
loop
wrdapp.Visible = True
end if
i guess i have explained my problem.i am dying to have a proper solution as early as possible.Thus any help will be gr8ly appreciated.
regards
Arnab Sengupta
Start With Different Page Number In Word Document
Hi,
I have a document within which there is a macro that fetches images (TIF Format) from a server and stores it locally on temp (c: emp). On pressing F11 on the document it compares the TIF filename from temp to the filename stored in the DB. If both the names match then the image is pasted or displayed on a new document, which is automatically created.
For each image displayed there is a corresponding title for it, which is captured from the DB and displayed in the Header. Simultaneously page numbers need to be displayed on the footer for the images.
A particular header can have more than one image. Once the header differs there is New Section Break, but the page number needs to continue. To add to that the user can add a different page number from the front end (a VB app) that is stored in the DB.
Issue is I can either get different headers to be displayed (based on the section break) or the page number to be displayed correctly (based on the page number entered from the VB App). I need both of them to be displayed in order to roll out this particular module.
Please Help !!!
Find below the code:
-------------------------------------------------------
Sub PictureMacro()
Dim oCn1 As ADODB.Connection
Dim oRs1 As ADODB.Recordset, oRs2 As ADODB.Recordset, oRs3 As ADODB.Recordset, oRs4 As ADODB.Recordset, oRs5 As ADODB.Recordset, oRs6 As ADODB.Recordset, oRs7 As ADODB.Recordset
Dim Directory As String, FType As String, FName As String
Dim connection1 As String, sSQLStmt1 As String, sSQLStmt2 As String, sSQLStmt3 As String, sSQLStmt4 As String, sSQLStmt5 As String, sSQLStmt6 As String, sFilename As String
Dim sDocket_Desc As String, Sub_Number As String, sSplit As String, sCurPage As String
Dim rng As Range, oRange As Range
Dim position As Integer, J As Integer, StartPage As Integer, Sub_Count As Integer
Dim v_start_page As Integer, v_end_page As Integer, v_tot_pages As Integer, CurPage As Integer
Dim Docid As Variant, Pageno As Variant, v_secid As Variant
Dim Docket_Desc As Variant, v_tmp As Variant, SecPages As Variant, temp_secid As Variant
Dim TifName() As Variant
Const DotPath As String = "\apsrv46hSaberAppealsPackageClerksPaper.dot"
'Connecting to DB
connection1 = "Provider=MSDAORA.1;" & _
"Password=scl_edms;" & _
"User ID=scl_edms;" & _
"Data Source=sclprod"
Set oCn1 = New ADODB.Connection
oCn1.Open connection1
'End of Connnection to DB
Directory = "c: emp"
FType = "*.tif"
With Application
.FileSearch.FileName = FType
.FileSearch.LookIn = Directory
.FileSearch.Execute
If .FileSearch.FoundFiles.Count > 0 Then
Documents.Add (DotPath)
End If
'For Retrieving the Starting Page # if entered in the Clerks Paper Form.
sSQLStmt3 = "select nvl(stpageno,0)as stpageno from scl_edms.appeals_pkg where id = (select min(id) from scl_edms.appeals_pkg) "
Set oRs3 = oCn1.Execute(sSQLStmt3)
StartPage = oRs3.Fields("stpageno").Value
'End of Retrieving the Starting Page #
'Count of number of sub doc numbers for appeals package
sSQLStmt6 = " select count(subdocnum) subcount from scl_edms.appeals_pkg "
Set oRs7 = oCn1.Execute(sSQLStmt6)
Sub_Count = oRs7.Fields("subcount").Value
'End of count of sub doc numebr for appeals package
' Initializing variables.
temp_secid = 0
v_tmp = ""
If (IsNull(StartPage) Or (StartPage = 0)) Then
v_start_page = 1
v_end_page = 0
Else
v_start_page = StartPage
v_end_page = v_start_page
End If
ReDim TifName(0)
'End of initializing variables
'Fetching of the TIF filename from the database
sSQLStmt4 = " select ap.docid, i.filename "
sSQLStmt4 = sSQLStmt4 + " from scl_edms.appeals_pkg ap, hv_user.hvdocument d, hv_user.hvdocsec s, hv_user.hvimages i "
sSQLStmt4 = sSQLStmt4 + " where ap.docid = d.docid and d.docid = s.docid and s.secid = i.secid "
sSQLStmt4 = sSQLStmt4 + " order by ap.id "
Set oRs5 = oCn1.Execute(sSQLStmt4)
'End of fetching of TIF Filename from DB
J = 1
Do While Not oRs5.EOF
Docid = oRs5.Fields("docid").Value
TifName(0) = oRs5.Fields("filename").Value
TifName(0) = CStr(J) & "_" & TifName(0) & ".tif"
.FileSearch.FileName = TifName(0)
FName = "c: emp" + TifName(0)
sSplit = Mid$(FName, Len(Directory) + 2)
position = InStr(sSplit, "_")
sFilename = Left$(sSplit, Len(sSplit) - 4)
sFilename = Right$(sFilename, Len(sFilename) - position)
'Query to get Docket Description and Sub Doc Number from Appeals Package table and Docket table
sSQLStmt1 = " select substr(ap.DOCKET_NAME, 1,100)docket_name, dk.SUB_NUMBER, i.filename, dk.docid, i.secid "
sSQLStmt1 = sSQLStmt1 + " from hv_user.hvimages i, hv_user.hvdocument d, hv_user.hvdocsec s, hv_user.hvvolume v, scl_edms.docket dk, scl_edms.appeals_pkg ap "
sSQLStmt1 = sSQLStmt1 + " where ap.docid = dk.docid and dk.docid = d.docid and d.docid = s.docid and s.secid = i.secid and i.volid = v.volid "
sSQLStmt1 = sSQLStmt1 + " and ap.docid = '" + CStr(Docid) + "' "
Set oRs1 = oCn1.Execute(sSQLStmt1)
'End of Docket Information Retrieval
Docket_Desc = oRs1.Fields("docket_name").Value
Sub_Number = oRs1.Fields("sub_number").Value
v_secid = oRs1.Fields("secid").Value
CurPage = Selection.Information(wdActiveEndAdjustedPageNumber)
'Retrieving the max page number for the specific secid
sSQLStmt3 = " select max(a.pageno) as pageno from hv_user.hvimages a, hv_user.hvdocsec b "
sSQLStmt3 = sSQLStmt3 + " where b.Docid = Docid and a.secid = '" + CStr(v_secid) + "' "
sSQLStmt3 = sSQLStmt3 + " and b.secid = a.secid "
Set oRs4 = oCn1.Execute(sSQLStmt3)
Pageno = oRs4.Fields("pageno").Value
'End of retrieving the max page number
'Display of Page Number in the Footer on the right
If StartPage = 0 Then
Selection.InlineShapes.AddPicture FileName:=FName, _
LinkToFile:=False, SaveWithDocument:=True
Selection.ParagraphFormat.Alignment = wdAlignParagraphCenter
Selection.InsertBreak Type:=wdSectionBreakNextPage
Selection.Sections(1).Headers(wdHeaderFooterPrimary).Range.Font.Size = 9
Selection.Sections(1).Headers(wdHeaderFooterPrimary).Range.Text = Docket_Desc
Selection.Sections(1).Headers(wdHeaderFooterPrimary).LinkToPrevious = False
If (v_tmp = Docket_Desc) Then
v_end_page = (v_start_page + Pageno - 1)
Else
With Selection.Sections(1).Footers(wdHeaderFooterPrimary).PageNumbers
.NumberStyle = wdPageNumberStyleArabic
.IncludeChapterNumber = False
.ChapterPageSeparator = wdSeparatorHyphen
.RestartNumberingAtSection = False
.StartingNumber = v_start_page
End With
Selection.Sections(1).Footers(wdHeaderFooterPrimary).PageNumbers.Add PageNumberAlignment:= _
wdAlignPageNumberRight, FirstPage:=True
v_start_page = v_end_page + 1
v_end_page = (v_start_page + Pageno - 1)
v_tmp = Docket_Desc
End If
Else
'If user enters a different page number
Selection.InlineShapes.AddPicture FileName:=FName, _
LinkToFile:=False, SaveWithDocument:=True
Selection.ParagraphFormat.Alignment = wdAlignParagraphCenter
Selection.InsertBreak Type:=wdSectionBreakNextPage
'Selection.InsertBreak Type:=wdPageBreak
Selection.Sections(1).Headers(wdHeaderFooterPrimary).Range.Font.Size = 9
Selection.Sections(1).Headers(wdHeaderFooterPrimary).Range.Text = Docket_Desc
Selection.Sections(1).Headers(wdHeaderFooterPrimary).LinkToPrevious = False
If (v_tmp = Docket_Desc) Then
v_end_page = (v_start_page + Pageno - 1)
Else
'Currently commented as it does not display the correct page number
'With Selection.Sections(1).Footers(wdHeaderFooterPrimary).PageNumbers
' .NumberStyle = wdPageNumberStyleArabic
' .IncludeChapterNumber = False
' .ChapterPageSeparator = wdSeparatorHyphen
' .RestartNumberingAtSection = True
' .StartingNumber = v_start_page
'End With
' Selection.Sections(1).Footers(wdHeaderFooterPrimary).PageNumbers.Add PageNumberAlignment:= _
' wdAlignPageNumberRight, FirstPage:=True
'End of commented code
If Sub_Count > 1 Then
v_start_page = v_end_page + 1
v_end_page = (v_start_page + Pageno - 1)
Else
v_start_page = v_end_page '+ 1
v_end_page = (v_start_page + Pageno - 1)
End If
v_tmp = Docket_Desc
End If
End If
'End of Display of Page Number in the Footer on the right
'Adding # of pages for each section to the DB (Appeals_Pkg)
sSQLStmt2 = " update scl_edms.appeals_pkg "
sSQLStmt2 = sSQLStmt2 + " set pagenos = '" + CStr(v_start_page) + "'//'-'//'" + CStr(v_end_page) + "' "
sSQLStmt2 = sSQLStmt2 + " where docket_name = '" + Docket_Desc + "' and docid = Docid "
Set oRs3 = oCn1.Execute(sSQLStmt2)
'End of Adding # of pages to DB
With Selection.Font
.Name = "Arial"
.Size = 10
.Bold = True
End With
oRs5.MoveNext
J = J + 1
Loop
End With
oCn1.Close
End Sub
------------------------------------------------
Please HELP !!!
Thanks,
Rick
Building A Multipage Document From Single Page Word Documents.
I have been playing with the following code to produce a single document from multiple word documents and it is just not working. At one point it did work but now I am only getting a one page document. The source documents are coming from a directory and that works. In debug it loops correctly. I am at a loss. Thanks for all replies.
Set WordSelection = prtWordDoc.Content
WordSelection.Start = WordSelection.End
On Error Goto WordError
strFileName = Dir$(strPathName, 0)
Do While strFileName <> ""
If( Ucase(Left(strFileName,4)) = "CERT") Then
Goto GetNext
End If
WordSelection.InsertBreak constPageBreak
Set WordSelection = prtWordDoc.Content
WordSelection.InsertFile strPathName & strFileName
Set WordSelection = prtWordDoc.Content
WordSelection.Start = WordSelection.End
GetNext:
strFileName = Dir$()
Loop
prtWordDoc.saveas(strPathName & "tempDocs.doc")
Copy&Paste From Excel To An Embedded Word Doc Page 2
Im Having 2 problems.
1) How do u open the existing document without wiping out previous changes(like the bookmarks I added). The following code seems to create a new word doc instead of using the existing document embedded.
2) How would I Paste spreadsheet range onto Page2? Bookmarks?
The following code is what I have come up with so far:
Excel.ActiveWorkbook.Worksheets(1).Shapes("OBJECT 1").Select
Selection.Verb Verb:=xlPrimary
Excel.Range("Range").Copy
Word.Documents(1).Select
Word.ActiveDocument.Bookmarks(1).Select
Word.Selection.PasteSpecial
Excel.ActiveWorkbook.Worksheets(1).Shapes(1).OLEFormat.Activate
instead of the first two lines of code
[crystal Report] Avoid Printer From Ejecting Page After Printing A 3 Line Page
Im taking a printout in crystal report - but there are only 3 lines and after printing it goes to next page - but I dont want it to goto next page.
Instead I want it to continue the rest of the printing - which may be in some other report etc - to continue printing from where it left behind (maybe one or 2 lines break)
But after printing 3 lines it automatically ejects out the paper and goes to next page
How do I avoid this ?
Thanks
Edit by johnminkjan: Topic Title
Anjanesh
Edited by - johnminkjan on 9/7/2004 12:01:29 PM
RESOLVED - Can't Get Page Setup Dialog To Show Page Size Correctly
Hey guys and gals, I am hoping someone will have an idea on this one . . .
I am trying to show the page setup dialog and prepopulate the values of the page setup dialog before it is shown. All of the form pre-population seems to work except paper size. I can retrieve paper size just fine after the user clicks ok on the form, I just can't seem to set it before the form is populated.
I created a tiny test app to illustrate my problem.
VB Code:
' on a formOption Explicit Private Sub Command1_Click() With Printer' Height & Width; Printer object — the physical dimensions' of the paper set up for the printing device; not available' at design time. If set at run time, values in these properties' are used instead of the setting of the PaperSize property.' .Width = 14' .Height = 8.5 .PaperSize = vbPRPSLegal .Orientation = vbPRORLandscape End With ShowPageSetupDlg MeEnd Sub '********************************************************************' IN A MODULE! Option Explicit Const CCHDEVICENAME = 32Const CCHFORMNAME = 32Const GMEM_MOVEABLE = &H2Const GMEM_ZEROINIT = &H40Const DM_DUPLEX = &H1000&Const DM_ORIENTATION = &H1&Const PSD_MARGINS = &H2Const PSD_DISABLEPRINTER = &H20Const PSD_INTHOUSANDTHSOFINCHES As Long = &H4Const PSD_DISABLEPAPER As Long = &H200 Private Declare Function PageSetupDlg Lib "comdlg32.dll" _ Alias "PageSetupDlgA" (pPagesetupdlg As PageSetupDlg) As Long Private Declare Sub CopyMemory Lib "kernel32" _ Alias "RtlMoveMemory" _ (hpvDest As Any, _ hpvSource As Any, _ ByVal cbCopy As Long) Private Declare Function GlobalLock Lib "kernel32" _ (ByVal hMem As Long) As Long Private Declare Function GlobalUnlock Lib "kernel32" _ (ByVal hMem As Long) As Long Private Declare Function GlobalAlloc Lib "kernel32" _ (ByVal wFlags As Long, _ ByVal dwBytes As Long) As Long Private Declare Function GlobalFree Lib "kernel32" _ (ByVal hMem As Long) As Long Private Type POINTAPI x As Long Y As LongEnd TypePrivate Type RECT Left As Long Top As Long Right As Long Bottom As LongEnd TypePrivate Type PageSetupDlg lStructSize As Long hwndOwner As Long hDevMode As Long hDevNames As Long flags As Long ptPaperSize As POINTAPI rtMinMargin As RECT rtMargin As RECT hInstance As Long lCustData As Long lpfnPageSetupHook As Long lpfnPagePaintHook As Long lpPageSetupTemplateName As String hPageSetupTemplate As LongEnd TypePrivate Type DEVMODE_TYPE dmDeviceName As String * CCHDEVICENAME dmSpecVersion As Integer dmDriverVersion As Integer dmSize As Integer dmDriverExtra As Integer dmFields As Long dmOrientation As Integer dmPaperSize As Integer dmPaperLength As Integer dmPaperWidth As Integer dmScale As Integer dmCopies As Integer dmDefaultSource As Integer dmPrintQuality As Integer dmColor As Integer dmDuplex As Integer dmYResolution As Integer dmTToption As Integer dmCollate As Integer dmFormName As String * CCHFORMNAME dmUnusedPadding As Integer dmBitsPerPel As Integer dmPelsWidth As Long dmPelsHeight As Long dmDisplayFlags As Long dmDisplayFrequency As LongEnd Type Public Function ShowPageSetupDlg(frm As Form) As Boolean Dim DevMode As DEVMODE_TYPE Dim lpDevMode As Long Dim m_PSD As PageSetupDlg Dim bReturn As Integer On Error Resume Next 'Set the current orientation and duplex setting DevMode.dmDeviceName = Printer.DeviceName DevMode.dmFields = DM_ORIENTATION Or DM_DUPLEX' DevMode.dmPaperWidth = Printer.Width' DevMode.dmPaperLength = Printer.Height DevMode.dmOrientation = Printer.Orientation DevMode.dmPaperSize = Printer.PaperSize DevMode.dmDuplex = Printer.Duplex DevMode.dmSize = Len(DevMode) On Error GoTo 0 'Allocate memory for the initialization hDevMode structure 'and copy the settings gathered above into this memory m_PSD.hDevMode = GlobalAlloc(GMEM_MOVEABLE Or GMEM_ZEROINIT, Len(DevMode)) lpDevMode = GlobalLock(m_PSD.hDevMode) If lpDevMode > 0 Then CopyMemory ByVal lpDevMode, DevMode, Len(DevMode) bReturn = GlobalUnlock(m_PSD.hDevMode) End If With m_PSD .rtMargin.Top = 0.5 * 1000 .rtMargin.Bottom = 0.5 * 1000 .rtMargin.Left = 0.5 * 1000 .rtMargin.Right = 0.5 * 1000 .ptPaperSize.x = 14 * 1000 .ptPaperSize.Y = 8.5 * 1000 .lStructSize = Len(m_PSD) 'Set the structure size .hwndOwner = frm.hWnd 'Set the owner window .hInstance = App.hInstance 'Set the application instance .flags = PSD_MARGINS Or PSD_DISABLEPRINTER Or PSD_INTHOUSANDTHSOFINCHES End With 'Show the pagesetup dialog If PageSetupDlg(m_PSD) Then ShowPageSetupDlg = True' sngMarginTop = (m_PSD.rtMargin.Top) / 1000' sngMarginBottom = (m_PSD.rtMargin.Bottom) / 1000' sngMarginLeft = (m_PSD.rtMargin.Left) / 1000' sngMarginRight = (m_PSD.rtMargin.Right) / 1000' sngPageW = (m_PSD.ptPaperSize.x) / 1000' sngPageH = (m_PSD.ptPaperSize.Y) / 1000 ' Get DEVMODE structure from PRINTDLG lpDevMode = GlobalLock(m_PSD.hDevMode) CopyMemory DevMode, ByVal lpDevMode, Len(DevMode) Call GlobalUnlock(m_PSD.hDevMode) ' Set default printer properties On Error Resume Next If Not (Printer Is Nothing) Then Printer.Copies = DevMode.dmCopies Printer.Orientation = DevMode.dmOrientation Printer.PaperSize = DevMode.dmPaperSize' lPaperSize = DevMode.dmPaperSize Printer.PrintQuality = DevMode.dmPrintQuality End If On Error GoTo 0 End IfEnd Function
Thanks in advance for any insight!
**RESOLVED**Crystal Reports / Make Subreport Flow From Page To Page
I have a Crystal Report with a number of subreports. One of the details sections of the main report includes a subreport. I would like it if when I ran the report, it would allow the subreport to be split within several pages. Currently, the subreport shows up on page 2. I would like it to be split between pages one and two.
This is what makes this problem interesting. The subreport exists in the Details d section of the main report. Details d is not checked as Keep Together or New Page Before. The details section before Details d (Details c) is not checked for New Page After. If you go into edit subrebort for Details d, the Report Header has New Page Before checked off, but it is disabled (I can't change it).
How do I make this subreport flow across pages? Why is the Report Header section of my subreport checked for New Page Before but does not allow me to uncheck?
Crystal Reports - Cross Tab - Forcing Virtual Page On Every Page
I have created a crystal report which contains multiple detail sections (Da-Di). Each detail section contains a subreport, which contains a cross-tab.
I have done this because I need to create one excel spreadsheet which contains data from different types of cross tabs.
For example, one cross tab lists accounts and totals, the second lists accounts and totals by cost centre (17 of these), and a third lists accounts and totals by product group (11 of these).
I have lined up all the columns perfectly, and when I export to Excel (Data only), it works perfectly, and I get all the rows and columns of all the cross-tabs in one excel worksheet. Brilliant.
However, when I print, preview or export to pdf, I only see the "real" page and do not see any virtual pages that are shown in each of the sub-reports.
How can I print or view this from the main report and get the virtual pages as well, without stuffing up my export to excel?
Any suggestions would be greatly appreciated.
Tab Pages Lose Data Modifications When Switching From Page To Page
I have a Tabbed two-Page data entry and viewing form that allows the user to select a key from a listbox and view, delete, and alter 22 data items relating to the selected key. The list is bound to a dataset table. When the user selects an item in the listbox, all data (21 columns worth) relating to the key are displayed on the pages using the "rows().item()" feature to select the data from the dataset. The problem is, when I modify any of the data on one page and click on the other to modify more data, the data from the first page is reset to the original data. Is there a way to cause the tabpage feature to stop resetting the Key list selected index each time a different page tab is clicked? Thanks.
How To Retrieve Child Node Values From An Xml Page Into An Asp Page
Hi I am having a xml file which is generated by a server.I wanted to get some values into my asp page.
The values i need are code in the below tag
<upload-item code="9780020360780" timestamp="1023180336000" symbology="11"/>
and
title and description in the below tag
<parameter key="title" value="The Shipping News"/><parameter key="desc" value="Macmillan Publishing Company, Incorporated"/>
Importantly I have 2 sets of each values.You can see this in the attachment.I am able to get 1st set of values.To get them I am using the below
To get the code
Set y = objDom.documentElement.selectNodes("body/response/codes/mapped-code/upload-item")
varcode=y.item(0).getattribute("code")
Set x = objDom.documentElement.selectNodes("body/response/codes/mapped-code/mapping/parameter")
'if x.length>0 then
'varTitlekey = x.item(1).getattribute("key")
'varTitleValue = x.item(1).getattribute("value")
'varDescKey = x.item(2).getattribute("key")
'varDescValue = x.item(2).getattribute("value")
'Response.Write varTitlekey & varTitleValue
'Response.Write varDescKey & varDescValue
'end if
How to get the 2nd set of values??Any help?/Any good web sites??
URGENT: Data Report (Page Header On Each Page)
Hi,
I am using Data Report (why?!!) to print a bill. It contains the company name and other information such as date and total amount etc.
I am doing this by coding only. NO DATA ENVIRONMENT (!).
I have put a lable on the Page header and I am displaying the company name in that lable. It prints perfactly on the first page of the bill. But it does not appear on the second page of the bill. Instead it displays the remaining items of the bill from the beginning.
I want to print company name on each page of the bill. this is shown in the image.
Is there a way to get the out put like this?
Please help me. Its urgent.
Thank a ton in advance.
Page Up Page Down Not Working With Crystal Designer In VB Project
His all,
its been a long time i m having a problem using Crystal Report with Visual Basic Project.
Question 1:
--------------
Page Down and page up key doesnt work on crystal report previewer(crviewer control). though its working with Crystal Report IDE..but not with visual basic crviewer control.
when we press page down and page up key on report..it goes to the end of the page..not goes to the next page or previous page..
I m using VB6 with Crystal Report 9.
well .. may be few of you have experienced about this bug in crystal report.
Question 2:
--------------
if i want to catch the keypress on crviewer control and i set the form's KeyPreview property to yes..... it only catches Enter Key.. or Function keys.. none other than that..
so..
how should i trap the keys... and set the task for the specific keys.
need your help buddies...
thanks in advance
c ya
Page Flip/Page Curl Effect
I am making an intro for a game, and I have a book, that
I need it to look as if the pages are turning...
The only help I found was a JAVA applet, but I dont
want to embed a webbrowser. PLEASE HELP! Thanks
a million in advanced. If you know how to do this - u
are tha man.
Search Page For Data Access Page
NEWBY!!
I have created a Database in Access2000---I'm using a Data Access Page with Recordset to view each record. (Too many records)
Now, I need a SEARCH PAGE to search by either Company or Invoice Number or PO Number, (I must be able to search by either one of the three listed) to open the Data Access Page. Once my record has been located, users will need to modifying and save text.
I tried creating another Data Access Page with Combo Boxes and Command Buttons that would open the Data Access Page, but was unsuccessful.
Help! ASAP
URGENT: Report/ Page Header On Each Page
Hi,
I am using Data Report (why?!!) to print a bill. It contains the company name and other information such as date and total amount etc.
I am doing this by coding only. NO DATA ENVIRONMENT (!).
I have put a lable on the Page header and I am displaying the company name in that lable. It prints perfactly on the first page of the bill. But it does not appear on the second page of the bill. Instead it displays the remaining items of the bill from the beginning.
I want to print company name on each page of the bill. this is shown in the image.
Is there a way to get the out put like this?
Please help me. Its urgent.
Thank a ton in advance.
MDI Form (Page Up/Page Down) Help Needed
I am working on making a few enhancements to a legacy VB Application and I've run into something I thought was going to be simple but has proven quite the opposite.
The application has an MDI Form with MANY child forms, some of which contain user controls that are almost forms unto themselves. The problem is that the forms and controls are causing the MDI Form to display scroll bars. The client wants to be able to use the Page Up and Page Down to go to the top and bottom respectively.
As you may or may no know, there is no KeyDown on an MDI Form and I can't even find anything on how to programmatically go to the top and bottom of the MDI Form.
Any ideas or suggestions will help.
Thanks in advance.
MDI Form (Page Up/Page Down) Help Needed
I am working on making a few enhancements to a legacy VB Application and I've run into something I thought was going to be simple but has proven quite the opposite.
The application has an MDI Form with MANY child forms, some of which contain user controls that are almost forms unto themselves. The problem is that the forms and controls are causing the MDI Form to display scroll bars. The client wants to be able to use the Page Up and Page Down to go to the top and bottom respectively.
As you may or may no know, there is no KeyDown on an MDI Form and I can't even find anything on how to programmatically go to the top and bottom of the MDI Form.
Any ideas or suggestions will help.
Thanks in advance.
DataReport Page By Page Total
Hi all!
Just an easy question. In my simple list datareport (for example store items) I would like to have a page total field and an incremental page total field for prices... Well, it seems very difficult!!!
Thanks a lot!
MDI Form (Page Up/Page Down) Help Needed
I am working on making a few enhancements to a legacy VB Application and I've run into something I thought was going to be simple but has proven quite the opposite.
The application has an MDI Form with MANY child forms, some of which contain user controls that are almost forms unto themselves. The problem is that the forms and controls are causing the MDI Form to display scroll bars. The client wants to be able to use the Page Up and Page Down to go to the top and bottom respectively.
As you may or may no know, there is no KeyDown on an MDI Form and I can't even find anything on how to programmatically go to the top and bottom of the MDI Form.
Any ideas or suggestions will help.
Thanks in advance.
MDI Form (Page Up/Page Down) Help Needed
I am working on making a few enhancements to a legacy VB Application and I've run into something I thought was going to be simple but has proven quite the opposite.
The application has an MDI Form with MANY child forms, some of which contain user controls that are almost forms unto themselves. The problem is that the forms and controls are causing the MDI Form to display scroll bars. The client wants to be able to use the Page Up and Page Down to go to the top and bottom respectively.
As you may or may no know, there is no KeyDown on an MDI Form and I can't even find anything on how to programmatically go to the top and bottom of the MDI Form.
Any ideas or suggestions will help.
Thanks in advance.
To Access Page Setup From ASP Page
I want to print web page programmatically without including header and footer. I can print by calling print function but also would like to access page setup proerties to disable header and footer and then reset back to original proeperties. please let me know ASAP. how can i do that using javascript or vb in asp age
Group Section - Extra Blank Page When Using The Option &"New Page After&"
In crystal report 9, I designed a report with a list of records grouped by card number. As I wanted each group to be printed on a different page, I went to the edit section for the group footer and select the "New Page After" option.
The problem is that when displaying / printing the report, there is always an extra page after the last group : it comes out with the header and the rest is blank.
How can I avoid this page to appear ?
Thanks for you help !
Separate A Document By Page
Hi all,
I am now working on a project that needs to separate a Word document into pages, i. e. the original document contains multiple pages, and separate each page to a new word file.
Can anyone help?
Qubeley
Count # Page Within Document?
Help..
Any one know how to count the number of page within a document?
Thank you..
Edited by - kunkhmer on 11/24/2003 3:08:21 PM
Dim In A Loop - VBScript For ASP Page
Is it possible to make dim statements in a loop and concatenate a variable name? I tried the following but it does not work.
arrCC() = objRS.getRows()
objRS.close
intFirstRec = Lbound(arrCC,2)
intLastRec = Ubound(arrCC,2)
for intCount = intFirstRec to intLastRec
strCCName = arrCC(1,intCount)
'dim various accumulators needed
dim "dblJob" & strCCName & "Hours"
dim "dblTot" & strCCName & "Hours"
dim "dblAdmin" & strCCName & "Hours"
next intCount
Trying To Copy To Another Page...
I'm trying to copy data to another page after I sort the data thats been inserted but the following code deletes most of the info from the pages it copies from. What's up with this code... am I not keeping it simple enough?
Code:
Sub RemoveDuplicates()
Application.ScreenUpdating = False
Dim WS As Worksheet
Dim WSCount As Integer, i As Integer, LastNum As Integer, LastInHiddenData As Integer
WSCount = Sheets.Count
i = 1
For Each WS In ActiveWorkbook.Worksheets
LastInHiddenData = LastNumberinRow(0) '<===| Last cell on "Hidden_Data" to paste to
If (WS.Name <> "Proposal Summary" And WS.Name <> "Proposal Cost Breakdown" And WS.Name <> "Hidden_Data") Then
Columns("O").AdvancedFilter Action:=xlFilterInPlace, Unique:=True
LastNum = LastNumberinRow(i) '<===| Reset last cell on page number to copy after the filtering
Range("O7:O" & LastNum).Copy '<---| Copy it
If i = 1 Then
Sheets("Hidden_Data").Select
Range("E1").Select
ActiveSheet.Paste '<---| Paste it in the first cell
Else
Sheets("Hidden_Data").Range("E" & LastHiddenData & ":E" & LastNum + LastHiddenData).Paste '<---| Paste it in the first available cell
End If
End If
i = i + 1 '<===| Increases page number to filter
Next WS
LastHiddenData = LastNumberinRow(0)
Sheets("Hidden_Data").Columns("O").AdvancedFilter Action:=xlFilterInPlace, Unique:=True
Application.ScreenUpdating = True
MsgBox "done filtering"
End Sub
Function LastNumberinRow(SheetNum As Integer) As Integer
On Error GoTo LRICError
Application.Volatile 'This will make sure that this function is called if anything is changed on the Worksheet
If SheetNum <> 0 Then
LastNumberinRow = Sheets(SheetNum).Cells(Rows.Count, 15).End(xlUp).Row
Else
LastNumberinRow = Sheets("Hidden_Data").Cells(Rows.Count, 5).End(xlUp).Row
End If
Exit Function
ExitFnxn:
Exit Function
'If there's an error in this function, then return an error to Excel
LRICError:
LastNumberinRow = CVErr(xlErrNA)
Resume ExitFnxn
End Function
It copies, pastes, quits and screws my worksheets up.
How To Set Page Format = A3 In VB6
Hello, is it possible to switch the page format from A4 to A3 programmatically when printing?
I tried changing the Printer.Height property, but I did not succeed.
Any help will be appreciated.
Printing A Document With Page X Of Y Gets Y Wrong.
Strangest thing with Page X of Y. If I stop the program before the ActiveDocument.PrintOut Background:=0 instruction then the Page X of Y numbers seem correct. If I let the program fly then the 'Y' stays as 2 which was the template document's value in the Footer. Does anybody have any ideas about this ?
How Do I Print And Save Only The First Page Of A Document?
Sounds like a silly question... I know. Basically, if a value in my Access database is less than 2, I need to delete the second page of a word document and then save and print it. It should look something like this:
If x < 2 then
objWord.ActiveDocument.DeleteSecondPage
end if
objWord.ActiveDocument.PrintOut (acPrintAll)
objWord.ActiveDocument.SaveAs....
Nothing complicated, I just can't figure out the commands. Any help would be greatly appreciated.
|