How to remove reference and Use vba code for every machine?

خرید بک لینک

As you suggested I have done changes but still I am not able to make it user-friendly or you can say every time when i have to use this code I have to tu on Scripting Runtime on different computers.Please suggest and make my code corrected as soon as possible Below is my code :-

Option Explicit Public fs As Object

Sub GetFileNamesandPageCount()

Dim diaFolder As FileDialog Set fs = CreateObject("Scripting.FileSystemObject") Dim i As Integer Dim fld As Object Dim T_Str As String Set diaFolder = Application.FileDialog(msoFileDialogFolderPicker) diaFolder.AllowMultiSelect = False diaFolder.Show If diaFolder.Show = -1 Then T_Str = diaFolder.SelectedItems(1) Else Set diaFolder = Nothing End If Set fld = fs.getfolder(T_Str) Dim wdOBJ As Word.Application Dim wdDoc As Object Dim fd As Object

Sheet1.UsedRange.Clear
Sheet1.Range("A1") = "Document Name"
Sheet1.Range("B1") = "Page Count"
Sheet1.Range("A1:B1").Font.Bold = True
Sheet1.Columns("A:A").ColumnWidth = 70
Sheet1.Columns("B:B").AutoFit
Sheet1.Range("A1:B1").Interior.ColorIndex = 37
fs.GetSpecialFolder (1)
Set wdOBJ = CreateObject("Word.Application")
wdOBJ.Visible = True
i = 1

For Each fd In fld.Files
    If (InStr(1, fd, ".doc") > 0) Or (InStr(1, fd, ".docx") > 0) Or (InStr(1, fd, ".docm") > 0) Or (InStr(1, fd, ".doct") > 0) Or (InStr(1, fd, ".pdf") > 0) Then
        Sheet1.Range("A" & i + 1) = fd.Name
        Set wdDoc = wdOBJ.Documents.Open(CStr(fd))
        wdDoc.ComputeStatistics (wdStatisticPages)
        Sheet1.Range("B" & i + 1) = wdDoc.BuiltinDocumentProperties(14)

        wdDoc.Close False
    End If
    i = i + 1
Next fd

wdOBJ.Quit False

End Sub

Recent Questions...

ما را در سایت Recent Questions دنبال می‌کنید

برچسب: نویسنده: استخدام کار بازدید: 297 تاريخ: سه شنبه 29 تير 1395 ساعت: 17:59

صفحه بندی