Monday, February 25, 2008

Write VBA Macro for Copy and paste the content of one workbook to another workbook.

Hi guys,
This is very easy task.This VBA(Macro will help you to copy one excel workbook in new excel workbook.
just copy the code and paste in your VBA editor and run it

Set Sourcebook = Workbooks.Open(filepath.Text)
count = Sourcebook.Sheets.count
' COUNT THE TOTAL NUMBER OF SHEET IN SOURCE WORKBOOK
name = Sourcebook.namename = Replace(name, ".xls", "_temp")
'CREATE NEW WORKBOOK
Set Destibook = Workbooks.Add
' LOOP FOR COPY THE ALL DATA FROM SOURCE WORKBOOK TO DESTINATION WORKBOOK
For sht = 1 To count
If sht > 3 Then
Destibook.Sheets.Add after:=Sheets(Sheets.count)
' ADD NEW SHEET IN DESTINATION BOOK
End If
Set sh2 = Destibook.Sheets(sht)
Set sh1 = Sourcebook.Sheets(sht)
Destibook.Sheets(sht).name = Sourcebook.Sheets(sht).name
'ASSIGN THE SHEET NAME
With sh1
Set SourceRange = .Range("A1:" & RDB_Last(.Cells))
.Range("A1:" & RDB_Last(.Cells)).Copy
' COPY THE SELECTED DATA FROM SOURCE BOOK
End With
With sh2
.Range("A1 :" & RDB_Last(.Cells)).PasteSpecial xlPasteFormats
End With
With sh2
.Range("A1 :" & RDB_Last(.Cells)).PasteSpecial xlPasteValuesAndNumberFormats End With
Next
With Destibook
On Error Resume Next
.SaveAs Filename:=name
' SAVE THE DESTINATION BOOK IN SAME LOCATION WHERE THE SOURCE BOOK
End With
MsgBox " FILE IS CONVERTED SUCESSFULLY.."
End

----------------------------------------------------------------

'USER DEFINE FUNCTION SELECTING THE RANGE

Function RDB_Last(rng As Range)
Dim lrw As Long
Dim lcol As Integer
On Error Resume Next
lrw = rng.Find(What:="*", _ after:=rng.Cells(1), _ Lookat:=xlPart, _LookIn:=xlFormulas, _ SearchOrder:=xlByRows, _ searchdirection:=xlPrevious, _Matchcase:=False).Row
On Error GoTo 0
On Error Resume Next lcol = rng.Find(What:="*", _
after:=rng.Cells(1), _ Lookat:=xlPart, _ LookIn:=xlFormulas, _ SearchOrder:=xlByColumns, _ searchdirection:=xlPrevious, _ MatchCase:=False).Column
On Error GoTo 0
On Error Resume Next
RDB_Last = Cells(lrw, lcol).Address(False, False)
If Err.Number > 0 Then
RDB_Last = rng.Cells(1).Address(False, False)
Err.Clear
End If
On Error GoTo 0
End Function
-----------------------------------------------------
Please give me your feedback.
if you want more information . comment me
thanks

Sunday, February 24, 2008

Load Sucessfully Excel Workbook in Excel Web Access Webpart in MOSS 2007

Hi friend,

If you want to try to load the excel file or workbook (Feature availabel that is not supported by Excel web Services) in EWA web part in Microsoft sharepoint server 2007 (MOSS 2007) then it genrates some errors like.

  • Feature not supported.
  • You can not load this file.
  • Unsupported features are availabel in this workbook.

Then What you will do for that.but don't worry guys,

I have solution for this.

You can do something like this,what i have done in my project.

I just write a simple macro for that, what you can write a Macro( VBA ) for copy whole excel workbook in another new Excel workbook.

It's very simple if you have any problem then write me, i will help you for that.

Thanks

Why MOSS 2007

Hi Friends,

Microsoft Office SharePoint Server 2007 (MOSS) is an integrated suite of server capabilities related to Web content management, document and records management, business process integration and forms, and business intelligence. It is a super-powerful Content Management System.