सुनिश्चित नहीं हैं कि अगर यह अभी भी प्रासंगिक है, लेकिन मैं इस तरह से
Public bEnableEvents As Boolean
Public bclickok As Boolean
Public booRestoreErrorChecking As Boolean 'put this at the top of the module
Private Declare Function apiGetComputerName Lib "kernel32" Alias _
"GetComputerNameA" (ByVal lpBuffer As String, nSize As Long) As Long
Private Declare Function apiGetUserName Lib "advapi32.dll" Alias _
"GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long
Function GetUserID() As String
' Returns the network login name
On Error Resume Next
Dim lngLen As Long, lngX As Long
Dim strUserName As String
strUserName = String$(254, 0)
lngLen = 255
lngX = apiGetUserName(strUserName, lngLen)
If lngX <> 0 Then
GetUserID = Left$(strUserName, lngLen - 1)
Else
GetUserID = ""
End If
Exit Function
End Function
यह अगले बिट मैं पीडीएफ के रूप में फाइल को सेव उपयोग करें, लेकिन बदल सकते हैं सूट करने के लिए
Public Sub SaveToDesktop()
Dim LoginName As String
LoginName = UCase(GetUserID)
ChDir "C:\Users\" & LoginName & "\Desktop\"
Debug.Print LoginName
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
"C:\Users\" & LoginName & "\Desktop\MyFileName.pdf", Quality:=xlQualityStandard, _
IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:= _
True
End Sub
havent कि के बारे में सोचा! +1 –
@mehow मैंने केवल अतीत में इसके बारे में सोचा है क्योंकि मेरा नहीं है;) – SWa
क्या मेरे उपयोगकर्ता मशीनों पर उस कोड को चलाने के लिए आवश्यक कोई विशेष संदर्भ, फ़ाइलें, आवश्यक होने की आवश्यकता होगी? –