2013-04-17 81 views
1

我想弄清楚如何將Excel電子表格從映射驅動器移動到SharePoint。SharePoint + Excel與宏

我們有一個工程部門,他使用這個電子表格來保存活動的工作和工作號碼列表。

它打破了這樣的:

用戶打開作業跟蹤電子表格和輸入信息 在最後一個選項卡,還有一個紅色的按鈕,去到另一個Excel工作簿,提供下一個可用的工作數量和產生工作跟蹤電子表格,其中紅色按鈕是。

是點擊紅色按鈕時運行的代碼:

Private Sub CommandButton1_Click() 
    Dim JTS As String 
    Dim yRow, UseRow 
    Dim Msg, Style, Title, Help, Ctxt, Response, Msg1, Msg2, Msg3 

    UnProtect_Files 

    If Worksheets("HANDOVER").Range("Job_No") <> "" Then GoTo JobFill1 
    If Len(Worksheets("HANDOVER").Range("C4")) < 1 Then GoTo WhereCust1 

    JTS = "P:\Job Tracking\Job Tracking Spreadsheet.xls" 

    On Error GoTo Lock1 

    OpBkNow: 
    Workbooks.Open (JTS) 

    'Look for available Job# in Job Tracking Spreadsheet 

    For yRow = 23 To 10000 
    If Workbooks("Job Tracking Spreadsheet.xls").Worksheets("Proposed-Active").Cells(yRow, 2) = "" Then UseRow = yRow: Exit For Next yRow 
    'This should never happen, but if there is no available Job#, print msg and exit sub 
    If UseRow < 23 Or UseRow > 10000 Then GoTo RowNtFnd 


    'Make changes to Job Tracking Spreadsheet 
    ThisWorkbook.Worksheets("Formulas").Range("B98") = Workbooks("Job Tracking Spreadsheet.xls").Worksheets("Proposed-Active").Cells(UseRow, 1) 
    Workbooks("Job Tracking Spreadsheet.xls").Worksheets("Proposed-Active").Cells(UseRow, 2) = ThisWorkbook.Worksheets("HANDOVER").Range("C4") 
    ThisWorkbook.Worksheets("HANDOVER").Range("Job_No") = ThisWorkbook.Worksheets("Formulas").Range("B98") 
    Workbooks("Job Tracking Spreadsheet.xls").Worksheets("Proposed-Active").Cells(UseRow, 3) = ThisWorkbook.Worksheets("HANDOVER").Range("D7") 

    GoTo QuitSb2 

    RowNtFnd: 
    Msg = "There are no available Job Numbers in the Job Tracking Spreadsheet. You will need to manually add one." 
    Style = vbOKOnly: Title = "Job Number Not Found": Help = "": Ctxt = 0 
    Response = MsgBox(Msg, Style, Title, Help, Ctxt) 

    QuitSb2: 
    Workbooks("Job Tracking Spreadsheet.xls").Close SaveChanges:=True 
    GoTo QuitSb1 

    WhereCust1: 
    'No Owner Name Given 
    Msg = "An entry in the CUSTOMER field is required when generating a Job Number!" 
    Style = vbOKOnly: Title = "Need Customer Info - Try Again": Help = "": Ctxt = 0 
    Response = MsgBox(Msg, Style, Title, Help, Ctxt) 
    GoTo QuitSb1 

    JobFill1: 
    'There is already a generated job number 
    Msg1 = "A Job Number (" 
    Msg2 = Worksheets("HANDOVER").Range("Job_No") 
    Msg3 = ") has already been generated for this job!" 

    Msg = Msg1 & Msg2 & Msg3 
    Style = vbOKOnly: Title = "Job Number Exists": Help = "": Ctxt = 0 
    Response = MsgBox(Msg, Style, Title, Help, Ctxt) 
    GoTo QuitSb1 

    Lock1: 
    'There is already a generated job number 
    Msg1 = "The Job Tracking spreadsheet is currently in use. " 
    Msg2 = "Please try to generate a Job Number later." 
    Msg = Msg1 & Msg2 
    Style = vbOKOnly: Title = "File In Use": Help = "": Ctxt = 0 
    Response = MsgBox(Msg, Style, Title, Help, Ctxt) 
    GoTo QuitSb1 

    QuitSb1: 

    'RER 3-29-05 remove auto file create as per Scott Penatzer request 
    'Create_New_File 

    Protect_Files 
End Sub 

這可能是更容易做到這一切的另一種方式,但最終企業寧願我改變什麼。是否有可能讓SharePoint上的多個文檔彼此通信並完全避免網絡共享?請儘快告知。

非常感謝您提前。

+1

歡迎來到Stackoverflow。使用Ctrl-K格式化代碼塊並添加一些換行符和縮進。你更有可能以這種方式得到答案。祝你好運。 – GrandMasterFlush

+0

謝謝。我做了這個格式來反映它是代碼。希望有人能夠更好地幫助我。我接受所有建議,只是試圖在SharePoint中完成這項工作。 – Joey

回答

0

是的,您可以通過SharePoint進行文件通信。轉到SharePoint中的庫,單擊功能區中的「在資源管理器中打開」。這會給你文件的文件夾位置。您應該能夠像映射的驅動器位置一樣引用該URL並打開/更新/保存SharePoint文件。祝你好運。