Search Results:

Saturday, July 16, 2016

Simple Code to get First Day of Week and Last Day of Week

I wanted a simple and quick way to get the start of week and end of week to do some data processing for the week. Here is a simple three line code that can help achieve this.

        DateTime dt  = DateTime.Now();
        DateTime FirstDayofWeek = dt.AddDays(-(int)dt.DayOfWeek);
        DateTime LastDayofWeek = FirstDayofWeek.AddDays(6);

Hope it helps, Thanks!!!

Thursday, July 14, 2016

Get PageNames in SSRS for SubReports.


I was recently presented with a situation where i need to place chart on one sheet and data in other sheet when exported to excel in SSRS. I tried to use page break after the chart and inserted a sub report.

When i did that, i noticed that that page names cannot be set for sub reports. In order to acheive something like below. I looked at work arounds to make the page names as shown in below image.


I noticed that the PageName property is available one tablix and rectangles. So i just placed a rectangle and set its PageName as "Other Custom Name 1" and then insert the subreport within this rectangle control and then the exported excel sheet hast the custom names as expected.



Let me know if you  have any other work arounds or if you found this post helpful.

Thank you.

Tuesday, July 5, 2016

Difference between a KeyPress and KeyDown Events

The KeyDown event triggers for all the keys where as KeyPress only works for the character keys.

For example:

If you press Key A, then it will fire KeyDown as well as KeyPress event.

If you press Shift,Ctrl, Escape or BackSpace keys then only KeyDown is the only


Refer:MSDN Link

Thursday, June 16, 2016

Filter datatable using LINQ in VB.NET

Below is a simple LINQ that you can use to filter the DataTable.


AsEnumerable() method to return the input type DataTable as IEnumerable.

CopyToDataTable() method takes the results of the filtered query and copies into a new DataTable that you can use to work with the filtered data.

-------------------------------------------------------------------------
         Dim filteredTable As DataTable = (From n In dt.AsEnumerable()
                                           Where n.Field(Of Int32)("id") = 1
                                           Select n).CopyToDataTable()
-------------------------------------------------------------------------

Feel free to leave your comments or suggestions. Thank you.

Wednesday, October 30, 2013

Adding Handlers for Controls {Code}

Public Class Userdetails
Dim cnn As SqlConnection = New SqlConnection(My.Settings.ConnectionString)
Dim strSQL As String
Private pUserId As Integer
Private pNewUser As Boolean = False
Private IsDirty As Boolean = False
Private Sub AddSaveHandlers(ByVal c As Control)
For Each ctrl As Control In c.Controls
If ctrl.Controls.Count > 0 Then
AddSaveHandlers(ctrl)
End If
Select Case ctrl.GetType.Name.ToUpper
Case "TEXTBOX", "COMBOBOX"
AddHandler ctrl.TextChanged, AddressOf SetPromptSaveTrue
Case "CHECKBOX"
AddHandler CType(ctrl, CheckBox).CheckStateChanged, AddressOf SetPromptSaveTrue
End Select
Next
End Sub
Private Sub SetPromptSaveTrue(ByVal sender As System.Object, ByVal e As System.EventArgs)
IsDirty = True
End Sub
Private Sub Userdetails_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
AddSaveHandlers(Me)
End Sub
Private Sub Userdetails_FormClosing(ByVal sender As System.Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles MyBase.FormClosing
Dim savedata As DialogResult
If IsDirty Then
savedata = MessageBox.Show("Do you want to save your changes?", "Save Changes", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1)
Select Case savedata
Case Windows.Forms.DialogResult.Yes
Call btnSave_Click(sender, e)
Case Windows.Forms.DialogResult.Cancel
e.Cancel = True
Case Else
IsDirty = False
End Select
End If
End Sub
Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click
End Sub
Private Sub btnCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCancel.Click
Me.Close()
End Sub
End Class

VSS Writers and associated Services

Handreference linking VSS Writers to Services


VSS Writer Service Name Service Display Name

ASR Writer
VSS Volume Shadow Copy
BITS Writer BITS Background Intelligent
Transfer Service

COM+ REGDB Writer
VSS Volume Shadow Copy
IIS Config Writer AppHostSvc Application Host Helper
Service

IIS Metabase Writer
IISADMIN IIS Admin Service
Microsoft Exchange Writer MSExchangeIS Microsoft Exchange
Information Store
Microsoft Hyper-V VSS Writer vmms Hyper-V Virtual Machine
Management
Registry Writer VSS Volume Shadow Copy

Shadow Copy Optimization Writer
VSS Volume Shadow Copy

System Writer
CryptSvc Cryptographic Services

WMI Writer
Winmgmt Windows Management
Instrumentation

Thursday, October 17, 2013

Convert a Base64 String into a PDF File

Recently I had the need to decode a Base64 string and make a PDF of it.  Usually I would've written a small utility app, but this time I rolled with powershell: 

function decodeBase64IntoPdf([string]$base64EncodedString)
{
    $bytes = [System.Convert]::FromBase64String($base64EncodedString)
    [IO.File]::WriteAllBytes("C:\Users\medmondson\Desktop\file.pdf", $bytes)
}

I'm impressed with how quickly I can knock out a script like this (yes they are .NET assemblies) without having to load a new VS solution. Of course a lot more could be done to this (file format via an argument for example) but I thought I'd share it raw as I know I'll need to use it again one day.

From Matt's Blog


Thursday, May 27, 2010

Tuesday, May 25, 2010

Why Invisible Column?

One might ask that why should I use an invisible column in the first place. There are many reasons of making the column invisible. You might want to use a column as the primary key which retrieves the value from the database and display it using the GridView control. Since, primary key is a confidential data you want might to hide it from the users. Another reason of making the column invisible is that you might want to have some additional information to save an extra trip to the database. Please note that the second scenario should not be used to display many columns as this will increase the View State and thus the size of the page large.

Using the DataKeys Property:

The simplest way to access the primary key is by using DataKeys property of the GridView control. DataKeys property represents the column which is to be used as the primary key. In this article I will use my custom database "Tasks" and display the columns "Title", "Description", "DateCreated" in the GridView control. Apart from the columns from the database the GridView also contains a CheckBox Template Column which is used to check the tasks which are completed. Take a look at the HTML below to have a clear idea.

<asp:GridView ID="gvInComplete" runat="server" AutoGenerateColumns="False" CellPadding="4"

ForeColor="#333333" GridLines="None" DataKeyNames="TaskID">

<FooterStyle BackColor="#990000" Font-Bold="True" ForeColor="White" />

<Columns>

<asp:BoundField DataField="Title" HeaderText="Title" />

<asp:BoundField DataField="Description" HeaderText="Description" />

<asp:BoundField DataField="DateCreated" HeaderText = "Date Created" />

<asp:TemplateField HeaderText="Select">

<ItemTemplate>

<asp:CheckBox ID="chkSelect" runat="server" />

ItemTemplate>

asp:TemplateField>

Columns>

asp:GridView>

As, you can see in the code above the DataKeyNames property is set to "TaskID" which, is the primary key in the table. Now, let's see how we can access all the TaskID of the rows which are checked using the CheckBoxes.

DataKey key;

foreach (GridViewRow row in gvInComplete.Rows)

{

bool result = ((CheckBox)row.FindControl("chkSelect")).Checked;

if (result)

{

key = gvInComplete.DataKeys[row.RowIndex];

Response.Write((int)key.Value);

}

}

In the code above I am iterating through all the rows in the GridView control. If I find a row that is checked then I gets the primary key of the row using the GridView DataKeys collection. The Row class property RowIndex will contain the index of the current row.

This is pretty simple right! But what if I want to access another column which is not a primary key. This can be done by using a Template Column inside the GridView control.

Accessing Invisible Column Using Template Field:

To access the invisible column using Template Field is very straight forward. All you need to do is to make the Template Field invisible and use the control inside the Template Field to access the values. Check out the following HTML code:

<asp:TemplateField Visible="False">

<ItemTemplate>

<asp:Label ID="lblTaskID" runat="server" Text='<%# Eval("TaskID") %>' />

ItemTemplate>

asp:TemplateField>

In the above HTML code I have simply defined a Label control inside the ItemTemplate property of the Template Field. The Template Field is made invisible so, the user will not see it on when it is bound to the GridView control. You can access the TaskID using the following code:

int taskID = 0;

Task task = new Task();

foreach (GridViewRow row in gvInComplete.Rows)

{

bool result = ((CheckBox) row.FindControl("chkSelect")).Checked;

if (result)

{

taskID = Convert.ToInt32(((Label)row.FindControl("lblTaskID")).Text);

task.UpdateTask(taskID);

}

}

In the above code I am simply iterating through the GridView rows and when I find that the checkbox is checked then I get the value from the Label control which in this case is TaskID. After, I get the TaskID I can perform any function on it in my case UpdateTask.

I hope you liked the article, happy coding!

Copied From:http://www.highoncoding.com/Articles/178_Access%20GridView%20Invisible%20Columns.aspx

This is just for educational purpose only....


Tuesday, May 18, 2010

Sending Email From Web Page using asp.net

Hope this link will help you find the solution you are looking

http://www.4guysfromrolla.com/articles/072606-1.aspx

Monday, May 10, 2010

Adding Images to Hyperlinks in Grid view.


A HyperLinkField enables authors to display text or image hyperlinks that users can click to navigate to another page.

The text or image of the hyperlink can either be static — the same for every row — or obtained from a field in the data source.

Similarly, the target page for the hyperlink can be a single page for all the hyperlinks, or a URL derived from the data source.

To add a hyperlink field

  1. Set the GridView control's AutoGenerateColumns property to false.
      autogeneratecolumns=false
    
    ...
    >
  2. Within the GridView declaration, declare a element.
  3. Within the Columns element, define the you intend to display, specifying at the very least the required DataTextField and DataNavigateUrlFields properties.
  4. Optionally set the HyperLinkField control's other properties, such as the HeaderText and DataNavigateUrlFormatString. For syntax, see GridView Control Syntax.
    
    

    hyperlinkfield headertext="Title"
    datatextfield="title"
    datanavigateurlfields="title_id"
    datanavigateurlformatstring="details_title.aspx?titleid={0}" />

    ...

GridView HyperLinkField Example
Run Sample | View Source

The HyperLinkField class itself does not have a member that directly supports using images. The HyperLink controls that are rendered in the column, though, include an ImageUrl property that can be set programmatically during the RowDataBound event of the GridView control to render image links.

To setup a hyperlink field to display images

  1. Set the GridView control's AutoGenerateColumns property to false.
  2. Assign the handler that will receive control when the rows are bound to data ( in effect, when the GridView's RowDataBound event occurs ).
      autogeneratecolumns=false
    
    ...
    onRowDataBound="getImages"
    >
  3. Proceed as with using text links above, except omit the Text and DataTextField properties.
    
    

    hyperlinkfield
    datanavigateurlfields="planId"
    datanavigateurlformatstring="plan_details.aspx?id={0}" />

    ...

  4. Define the handler for the event ( see demo ).

The following example shows how to set up a HyperLinkField to display a column of image links in a GridView control.

Dynamically Generated HyperLinkField Images
Run Sample | View Source

For additional information, see HyperLinkField in the class library.

This Article is copied from URL:http://authors.aspalliance.com/aspxtreme/webforms/controls/addinghyperlinkfieldstogridview.aspx

This is for Educational Purposes Only.

Friday, May 7, 2010

Another Way to Change Gridview Row Color on Mouse-Over

A need little feature that can jazz up any Gridview is adding a color-change when the mouse is over a row. Thanks to our good friend (or nemesis depending on your point of view) JavaScript, setting up such a thing is only a few lines of code away.

First, setup your Gridview. I’m sure you’ve done this thousands of times, so I won’t bore you with the code of setting up or populating this guy. Add an OnRowCreated event to your GridView. This will run for each row created in your Gridview and allow you to add the necessary JavaScript.
"gvNews"

runat="server"
AutoGenerateColumns="False"
DataKeyNames="BlogID"
DataSourceID="SqlDataSource1"
AllowPaging="True"
PageSize="20"
BorderStyle="None"
BorderWidth="0px"
Width="100%"
CellPadding="10"
CellSpacing="4"
ShowHeader="False"
OnRowCreated="gvNews_OnRowCreated"
>
In your code behind, you will need to add a handler for this event. For my example, I’m using alternating background colors on rows (which you should do too, it makes things so much more readable). This causes me to add a couple extra lines so that I make sure I’m setting my rows back to the correct color on MouseOut.
    protected void gvNews_OnRowCreated(object sender, GridViewRowEventArgs e)

{
if (e.Row.RowType == DataControlRowType.DataRow)
{
if (e.Row.RowState == DataControlRowState.Alternate)
{
e.Row.Attributes.Add("onmouseover", "this.style.backgroundColor='#FFFFE1';");
e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor='#f7fff8';");
}
else
{
e.Row.Attributes.Add("onmouseover", "this.style.backgroundColor='#FFFFE1';");
e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor='#eefef0';");
}
}
}
That’s all there is to it. If you want to see this in action, check out the news section on the main page here.

There is room for improvement here… you could assign a CSS class instead of hard coding the colors. I believe there is also a way you could also get the background color that is assigned in the RowStyle/AlternatingRowStyle section. That would make this much more portable.

Copied From :http://www.krissteele.net/blogdetails.aspx?id=78
Just for Educational Purposes only.

Color Gridview Rows on mouse over.

GridView Component had brought some really nice features to the ASP.Net development. And even those features that it lacks can be easily added via customization or inheritance.

One of the things that GridView lacks are all those client-side bells and whistles that make todays web users happy (or miserable, depending on how developers over-use them ).

For example, very often it is required to highlight the data rows when mouse pointer is over the row (Mouse Hover effect).

This is not something that GridView does by default, but as i said, it is very easy to add new features to the GridView.
We can add few lines of JavaScript and thats it.

But to create this effect in a way as it should be done, a little planning is necessary:

If you ask the almighty Google, it will direct you to the various implementations of this effect for GridView but most of them do not take into account GridView's ItemStyle and AlternatingItemStyle properties and just override them when changing row colors.

What we are going to do is to implement mouse hover row highlighting with respect of all GridView properties, and restoring their original values when the mouse pointer is moved away from the rows/GridView.

In order to highlight the row on mouse hover, we need to add some custom JavaScript code to onmouseover and onmouseout event handlers of the rows of our GridView.

We can do this by placing this code to the RowCreated event handler of our GridView:

protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e)

{

// only apply changes if its DataRow

if (e.Row.RowType == DataControlRowType.DataRow)

{

// when mouse is over the row, save original color to new attribute, and change it to highlight yellow color

e.Row.Attributes.Add("onmouseover",

"this.originalstyle=this.style.backgroundColor;this.style.backgroundColor='#EEFF00'");

// when mouse leaves the row, change the bg color to its original value

e.Row.Attributes.Add("onmouseout",

"this.style.backgroundColor=this.originalstyle;");

}

}


What this code actually does?

RowCreated event is fired immediately after each row is created in our GridView. So for each created row, we first check if its a DataRow (not Header of Footer for example) and if it is, we add the JavaScript code via Add method of the Attributes collection (AttributeCollection type) that has name-value pairs of the rendering attributes of the GridViewRow.

In onmouseover handler code, we first store (for later restoring) the original background color of the row in a custom attribute we called "originalstyle" and we then change it to a custom color (light Yellow in this case).

In onmouseout handler, we restore the original background color of the row from the "originalstyle" attribute.

And that is it. If you bind this GridView with some data and display it on a page, when you move your mouse pointer over any of the rows, it will change its background color into Yellow. And when you move mouse out of the row, the original background color of the row is restored.

IMPORTANT: This works correctly even if you have set the AlternatingRowStyle of the GridView and even if the row was previously selected (this detail is something that is missing in all other implementations of this GridView behavior we have seen on the internet).

Ok, now that we solved this, why not make a custom WebControl out of it by inheriting the original ASP.NET GridView control and adding highlighting feature to it?

Its really simple, here is the code of the HoverGridView custom WebControl:

using System;

using System.Data;

using System.Configuration;

using System.Web;

using System.Web.Security;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Web.UI.WebControls.WebParts;

using System.Web.UI.HtmlControls;

using System.Drawing;

///

/// Summary description for HoverGridView

///

namespace Roboblob.WebControls

{

[ToolboxData("<{0}:HoverGridView runat=server>")]

public class HoverGridView : System.Web.UI.WebControls.GridView

{

public bool MouseHoverRowHighlightEnabled

{

get

{

if (ViewState["MouseHoverRowHighlightEnabled"] != null)

return (bool)ViewState["MouseHoverRowHighlightEnabled"];

else

return false;

}

set { ViewState["MouseHoverRowHighlightEnabled"] = value; }

}

public Color RowHighlightColor

{

get

{

if (ViewState["RowHighlightColor"] != null)

return (Color)ViewState["RowHighlightColor"];

else

{

// default color

return Color.Yellow;

}

}

set { ViewState["RowHighlightColor"] = value; }

}

protected override void OnRowCreated(GridViewRowEventArgs e)

{

base.OnRowCreated(e);

if (MouseHoverRowHighlightEnabled)

{

// only apply changes if its DataRow

if (e.Row.RowType == DataControlRowType.DataRow)

{

// when mouse is over the row, save original color to new attribute

// and change it to highlight yellow color

e.Row.Attributes.Add("onmouseover",

string.Format("this.originalstyle=this.style.backgroundColor;this.style.backgroundColor='{0}'",

ColorTranslator.ToHtml(RowHighlightColor)));

// when mouse leaves the row, change the bg color to its original value

e.Row.Attributes.Add("onmouseout",

"this.style.backgroundColor=this.originalstyle;");

}

}

}

}

}

And here is how to use this custom WebControl on a WebForm:

First we must register it on the top of our aspx page:

<%@ Register Namespace="Roboblob.WebControls" TagPrefix="roboblob" %>


And when we place our custom GridView on the form here is how its declaration looks like:

<roboblob:HoverGridView runat="server" MouseHoverRowHighlightEnabled="True" RowHighlightColor="Green" ID="HoverGridView1" AutoGenerateColumns="False" DataKeyNames="id" DataSourceID="SqlDataSource1">

<Columns>

<asp:CommandField ShowSelectButton="True" />

<asp:BoundField DataField="id" HeaderText="id" InsertVisible="False" ReadOnly="True"

SortExpression="id" />

<asp:BoundField DataField="name" HeaderText="name" SortExpression="name" />

Columns>

roboblob:HoverGridView>


As you can see its really only a few lines of code, and yet we have created a custom WebControl that we can place on any WebForm, switch the highlighting on/off, change the highlight color etc.

This is the beauty of creating and using WebControls and Controls in general...

We could add many other features to our custom GridView, like different colors for alternating rows, for selected rows etc but i will leave that as something for you to play with.

Have fun!

Copied From : http://www.aspdotnetfaq.com/Faq/How-to-correctly-highlight-GridView-rows-on-Mouse-Hover-in-ASP-NET.aspx

Wednesday, November 25, 2009

Color Tabs of a Tabcontrol using VB.NET

In order to color the tabs of the tabcontrol in vb.net

just drop a tab control on a form with DrawMode = OwnerDrawFixed and put a couple of tab pages in it

1.
Private Sub TabControl1_DrawItem(ByVal sender As Object, ByVal e As System.Windows.Forms.DrawItemEventArgs) Handles TabControl1.DrawItem
2.
3.
'Firstly we'll define some parameters.
4.
Dim CurrentTab As TabPage = TabControl1.TabPages(e.Index)
5.
Dim ItemRect As Rectangle = TabControl1.GetTabRect(e.Index)
6.
Dim FillBrush As New SolidBrush(Color.Red)
7.
Dim TextBrush As New SolidBrush(Color.White)
8.
Dim sf As New StringFormat
9.
sf.Alignment = StringAlignment.Center
10.
sf.LineAlignment = StringAlignment.Center
11.
12.
'If we are currently painting the Selected TabItem we'll
13.
'change the brush colors and inflate the rectangle.
14.
If CBool(e.State And DrawItemState.Selected) Then
15.
FillBrush.Color = Color.White
16.
TextBrush.Color = Color.Red
17.
ItemRect.Inflate(2, 2)
18.
End If
19.
20.
'Set up rotation for left and right aligned tabs
21.
If TabControl1.Alignment = TabAlignment.Left Or TabControl1.Alignment = TabAlignment.Right Then
22.
Dim RotateAngle As Single = 90
23.
If TabControl1.Alignment = TabAlignment.Left Then RotateAngle = 270
24.
Dim cp As New PointF(ItemRect.Left + (ItemRect.Width \ 2), ItemRect.Top + (ItemRect.Height \ 2))
25.
e.Graphics.TranslateTransform(cp.X, cp.Y)
26.
e.Graphics.RotateTransform(RotateAngle)
27.
ItemRect = New Rectangle(-(ItemRect.Height \ 2), -(ItemRect.Width \ 2), ItemRect.Height, ItemRect.Width)
28.
End If
29.
30.
'Next we'll paint the TabItem with our Fill Brush
31.
e.Graphics.FillRectangle(FillBrush, ItemRect)
32.
33.
'Now draw the text.
34.
e.Graphics.DrawString(CurrentTab.Text, e.Font, TextBrush, RectangleF.op_Implicit(ItemRect), sf)
35.
36.
'Reset any Graphics rotation
37.
e.Graphics.ResetTransform()
38.
39.
'Finally, we should Dispose of our brushes.
40.
FillBrush.Dispose()
41.
TextBrush.Dispose()
42.
End Sub

Monday, November 16, 2009

Copy rows from one grid view to another grid view.

I haven't tried this code on my own but my friend used this code to bring this functionality, I just wanted to share so that someone might get benifitted from this code

The code is in VB.NET

If (e.Control And e.KeyCode = Keys.V) Then
Dim s As String = Clipboard.GetText()
Dim lines As String()
lines = System.Text.RegularExpressions.Regex.Split(s, Environment.NewLine)
'Dim row As Integer = dgv.CurrentCell.RowIndex
'Dim col As Integer = dgv.CurrentCell.ColumnIndex
Dim row, col As Integer
For intRow As Integer = 0 To dgv.RowCount - 1
For intCol As Integer = 0 To dgv.ColumnCount - 1
If dgv.Rows(intRow).Cells(intCol).Selected = True Then
row = intRow
col = intCol
Exit For
End If
Next
If Not (row = 0 And col = 0) Then
Exit For
End If
Next
For intNextLine As Integer = 0 To (lines.Length - 1)
If (row < dgv.RowCount And lines(intNextLine).Length > 0) Then
Dim cells As String() = System.Text.RegularExpressions.Regex.Split(lines(intNextLine), "\t")
For i As Integer = 0 To cells.Length - 1
If (col + i < dgv.ColumnCount) Then
dgv.Rows(row).Cells(col + i).Value = cells(i)
End If
Next
row = row + 1
End If
Next
End If

Wednesday, November 4, 2009

Code Sample to Combine two PDF files

How To: Combine PDFs Using InsertPages



Issue
How do I combine multiple PDFs into one PDF using Visual Basic?
Solution
This record contains VisualBasic code to demonstrate AcroExch.PDDoc InsertPages.

As far as InsertPages is concerned, the tricky part is to remember that the page number you will be inserting after is -1; in other words, you want to insert these pages before page 0, which is the first page of the document.

Private Sub Command1_Click()
Dim b As Boolean

Dim AcroPDDoc As CAcroPDDoc
Dim PDDoc As CAcroPDDoc

Set AcroPDDoc = CreateObject("AcroExch.PDDoc")
Set PDDoc = CreateObject("AcroExch.PDDoc")

b = PDDoc.Open("c:\testinsertpages.pdf")
b = AcroPDDoc.Open("c:\Tips.pdf")
b = AcroPDDoc.InsertPages(0, PDDoc, 0, 1, False)
b = AcroPDDoc.Save(1, "c:\Tips.pdf")

End Sub

Monday, November 2, 2009

Combine 2 PDF's Using vb.net

How To: Combine PDFs Using InsertPages



Issue
How do I combine multiple PDFs into one PDF using Visual Basic?
Solution
This record contains VisualBasic code to demonstrate AcroExch.PDDoc InsertPages.

As far as InsertPages is concerned, the tricky part is to remember that the page number you will be inserting after is -1; in other words, you want to insert these pages before page 0, which is the first page of the document.

Private Sub Command1_Click()
Dim b As Boolean

Dim AcroPDDoc As CAcroPDDoc
Dim PDDoc As CAcroPDDoc

Set AcroPDDoc = CreateObject("AcroExch.PDDoc")
Set PDDoc = CreateObject("AcroExch.PDDoc")

b = PDDoc.Open("c:\testinsertpages.pdf")
b = AcroPDDoc.Open("c:\Tips.pdf")
b = AcroPDDoc.InsertPages(0, PDDoc, 0, 1, False)
b = AcroPDDoc.Save(1, "c:\Tips.pdf")

End Sub

PDF Programming

A website for PDF programming help

Link is

http://www.nk-inc.com/blog/?page=2

Friday, October 16, 2009

Easily Create Loading GIF's for free

Here is a website to create a Loading GIF and save it to your desktop very easily. Give it a try ?? Click Here

A few samples below are



Another one

Wednesday, October 14, 2009

Disable Autorun of CD's,Pendrives etc

Here is the registry edit that can be done to disable the auto run feature in windows.
  1. Go to RUN type "Regedit".
  2. Go to Hkey_current_user/Software/Microsoft/windows/currentversion/policies/Explorer
  3. Add DWORD "NoDriveTypeAutoRun
  4. Edit the Value to Hexadecimal "FF"
You are set now the auto run is disabled.