1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
|
Sub Gmain_Ped_Out(Document As String, Excel_Workbook As String, Excel_Script_File As String, Specific_param As Variant)
'
' Gmain_Ped_Out Macro
' Macro enregistrée le 26/05/2006 par Admin
'
Dim lrow As Long
Dim xlrow As String
Dim Range_Id As String
Dim Temp_Range_Id As String
Dim off As Long
Dim Column_from As String
Dim Column_to As String
Workbooks.Open Filename:=Document
Windows(Excel_Workbook).Activate
ActiveSheet.UsedRange
ActiveSheet.UsedRange
Range_Id = Get_Range_Id(ActiveSheet.UsedRange.Name)
Column_from = Trim(Get_Column_From(ActiveSheet.UsedRange.Name))
Column_to = Trim(Get_Column_To(ActiveSheet.UsedRange.Name))
Range(Range_Id).Select
'**********************************************
'* real VB Script Start here *
'**********************************************
'Header Line In Bold
Range_Id = Column_from & "1:" & Column_to & "1"
Range(Range_Id).Select
Selection.Font.Bold = True
'Autofit
Range_Id = Column_from & ":" & Column_to
Columns(Range_Id).EntireColumn.AutoFit
Range("A1").Select
ActiveWorkbook.Save
ActiveWorkbook.Close
'**********************************************
'* real VB Script Stop here *
'**********************************************
Windows(Excel_Script_File).Activate
End Sub
Private Function Get_Range_Id(Temp_Range_Id As String) As String
Dim Range_Id As String
Dim off As Long
off = InStr(1, Temp_Range_Id, "!", vbTextCompare)
If off > 0 Then
Get_Range_Id = Right(Temp_Range_Id, Len(Temp_Range_Id) - off)
Else
Get_Range_Id = Temp_Range_Id
End If
End Function
Private Function Get_Column_From(Temp_Range_Id As String) As String
Dim Range_Id As String
Dim off As Long
Dim off2 As Long
off = InStr(1, Temp_Range_Id, "!", vbTextCompare)
If off > 0 Then
off2 = InStr(off + 2, Temp_Range_Id, "$", vbTextCompare)
If off2 > 0 Then
Get_Column_From = Mid(Temp_Range_Id, off + 2, off2 - (off + 2))
End If
End If
End Function
Private Function Get_Column_To(Temp_Range_Id As String) As String
Dim Range_Id As String
Dim off As Long
Dim off2 As Long
off = InStr(1, Temp_Range_Id, ":", vbTextCompare)
If off > 0 Then
off2 = InStr(off + 2, Temp_Range_Id, "$", vbTextCompare)
If off2 > 0 Then
Get_Column_To = Mid(Temp_Range_Id, off + 2, off2 - (off + 2))
End If
End If
End Function |
Partager