index > Visual Basic for Applications (VBA) > VBA script not accessing another workbook

VBA script not accessing another workbook


I have written a simple application for user that pulls information from another workbook. When my workbook is open, the source worksheet cannot be accessed, but when I shut my workbook down, the source workbook can be accessed. This was written using office 2003 but was saved in a 97 to 2003 format and the user is using windows xp. This is happening on the user's computer but not on my own which is on the same network.
Derek at Potters Clay
Derek, there could be several reasons you're experiencing technical difficulties. Too clear things up, could you post the VBA Code here for analysation.

Thanks,
halfazner =]
halfazner
Sub populate()

'total reps in team a at cell 2,9
'total reps in team b at cell 2,10
Dim repsa As Integer
Dim repsb As Integer
Dim monthcaps As String
Dim monthproper As String
Dim monthint As Integer
'monthint = Workbooks("Team Competition").Worksheets("Main").Cells(2, 12)
monthint = Worksheets("Main").Cells(2, 12)


Select Case monthint
Case 1
monthcaps = "JANUARY"
monthproper = "January"
Case 2
monthcaps = "FEBRUARY"
monthproper = "February"
Case 3
monthcaps = "MARCH"
monthproper = "March"
Case 4
monthcaps = "APRIL"
monthproper = "April"
Case 5
monthcaps = "MAY"
monthproper = "May"
Case 6
monthcaps = "JUNE"
monthproper = "June"
Case 7
monthcaps = "JULY"
monthproper = "July"
Case 8
monthcaps = "AUGUST"
monthproper = "August"
Case 9
monthcaps = "SEPTEMBER"
monthproper = "September"
Case 10
monthcaps = "OCTOBER"
monthproper = "October"
Case 11
monthcaps = "NOVEMBER"
monthproper = "November"
Case 12
monthcaps = "DECEMBER"
monthproper = "December"
End Select
Dim tempstring As String
Dim yearint As Integer
Dim dayint As Integer
' yearint = Workbooks("Team Competition").Worksheets("Main").Cells(2, 14)
' dayint = Workbooks("Team Competition").Worksheets("Main").Cells(2, 13)
' repsa = Workbooks("Team Competition").Worksheets("Main").Cells(2, 10)
' repsb = Workbooks("Team Competition").Worksheets("Main").Cells(2, 11)
yearint = Worksheets("Main").Cells(2, 14)
dayint = Worksheets("Main").Cells(2, 13)
repsa = Worksheets("Main").Cells(2, 10)
repsb = Worksheets("Main").Cells(2, 11)

Dim tempint As Integer


For i = 5 To (repsa + 5)
' tempint = ((Workbooks("Team Competition").Worksheets("Main").Cells(i, 2)) + 3)
tempint = (Worksheets("Main").Cells(i, 2)) + 3
tempstring = "='G:\Customer Service\Daily Sales Tracking Sheets\" & monthcaps & " " & yearint & " Sales Tracking\Kumfer Team\[" & monthcaps
tempstring = tempstring & " Kumfer Issued Sales Roll Up.xls]" & monthint & "-" & dayint & "'!$Q$" & tempint
Worksheets("Main").Cells(i, 4) = tempstring
'Workbooks("Team Competition").Worksheets("Main").Cells(i, 4) = tempstring
Next i

' With Workbooks("Team Competition").Worksheets("Main").Range("b3:d30").Interior
With Worksheets("Main").Range("b3:d30").Interior
.ColorIndex = 38
.Pattern = xlSolid
End With

' With Workbooks("Team Competition").Worksheets("Main").Range("f3:h30").Interior
With Worksheets("Main").Range("f3:h30").Interior
.ColorIndex = 33
.Pattern = xlSolid
End With

For j = 5 To (repsa + 5)
tempint = Worksheets("Main").Cells(j, 6) + 3
' tempint = ((Workbooks("Team Competition").Worksheets("Main").Cells(j, 6)) + 3)
tempstring = "='G:\Customer Service\Daily Sales Tracking Sheets\" & monthcaps & " " & yearint & " Sales Tracking\Kumfer Team\[" & monthcaps
tempstring = tempstring & " Kumfer Issued Sales Roll Up.xls]" & monthint & "-" & dayint & "'!$Q$" & ((Worksheets("Main").Cells(j, 6)) + 3)
' tempstring = tempstring & " Kumfer Issued Sales Roll Up.xls]" & monthint & "-" & dayint & "'!$Q$" & ((Workbooks("Team Competition").Worksheets("Main").Cells(j, 6)) + 3)
Worksheets("Main").Cells(j, 8) = tempstring
' Workbooks("Team Competition").Worksheets("Main").Cells(j, 8) = tempstring
Next j
' Workbooks("Team Competition").Worksheets("Main").Cells(1, 2) = monthproper & " " & dayint & ", " & yearint & " Team Competition"
Worksheets("Main").Cells(1, 2) = monthproper & " " & dayint & ", " & yearint & " Team Competition"






'='G:\Customer Service\Daily Sales Tracking Sheets\AUGUST 2006 Sales Tracking\Kumfer Team\[AUGUST Kumfer Issued Sales Roll Up.xls]8-15'!$Q$4





End Sub
Derek at Potters Clay
Could security on the program cause an issue due to macros?
Derek at Potters Clay
reply 4

You can use google to search for other answers

 

More Articles

• Accessing OLE object properties (powerpoint 2020)
• What is an error 400?
• How To Transfer Data to ADO Data Source from Excel with ADO
• question about word automation(how to insert header)
• Recursive Function
• How to build this??
• Using Inet to download an FTP File
• VBA text box! I'm completely lost...
• Clear Excel object
• Extract text within several tables in word document
Welcome to Bokebb   New Update   Joins the collection  
 

New Articles

• Select query returns non-existing data
• Dialog Box, Searching for keywords in an
• Run SQL Server 2005 DTS Package from MS
• Application Hosted Scripting IDE in .NET
• pls, help me to write a macro
• command line parameters to VBA in PPT?
• Command Buttons (Delete, Run, and Close)
• VBA, Access, & SQL Server
• Table or Array in the header of an excel
• Length of an Excel Macro?
• VBA TaskBox (Windows XP) & HTML Mult
• Personal.xls
• Problems when accessing a text file usin
• Put Certain E-mail Address in FROM Field
• VBA How to cope with unicode strings

Hot Articles

• Distribute elements extracted from XML
• how to change the picture when i change
• Tic Tac Toe Game
• Can a field result in a Query be formatt
• List Box Selection via Code (Access 2003)
• Detecting Excel Password
• ADOdb w/ SQL producing unspecified error
• Problem with Query in VBA code : Object.
• Can you tell me why Int(1.4 * 100) = 139
• Visio VBA Macro to detect connector endp
• checking for existence of a form
• Combo Box add items from excel column an
• Include a user-defined field in task vie
• Help required.....
• Global Variable not Persisting

Recommend Articles

• Set Folder property
• jump to other slides of a ppt by selecti
• Select Syntax problem in a Query
• Access/VBA add the value to ListBox ever
• VBA Shell Function / Windows API Create
• Need to copy Paragraphs from other docum
• Date validation on a form
• DBGrid and MSFlexGrid not working in VBA
• Getting Images embedded in Word
• create a chart based on QueryTable
• Referring to a range on another workshee
• Openening an Excel file from within Proj
• Shared Addin using Word
• Linking to an Oracle DB via MSAccess/VBA
• For Each & Variable Problem