T
trevorC via AccessMonster.com
Hi All,
I'm having trouble getting my code to work using sub procedures in my vba
code, this only happens when i am interacting with excel. I've tried to copy
all the dims and defs from the calling procedure but to no avail at this time.
sample code below.
Dim strPath As String
Dim rst As DAO.Recordset
Dim Excel_Application As Excel.Application
Dim Excel_Workbook As Excel.Workbook
Dim Current_Worksheet As Excel.Worksheet
Dim Data_Range
Dim Worksheet_Name
Dim db As Database
Dim rs As Recordset
D_now = Format(Date, "dd-mm-yy") ' Formated to use as part of file name
gg = "C:\Employee Time Report " & D_now & ".xls"
Is_File= Len(Dir(gg))
If Is_File= 0 Then
Else
T_Msg = MsgBox("File already exists, Delete file and continue ?.",
vbYesNo, "")
If T_Msg = vbYes Then
Kill gg
Else
Exit Sub
End If
End If
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, "Report Output",
gg, True
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, "Comments", gg,
True
Set Excel_Workbook = GetObject(gg)
Set Excel_Application = Excel_Workbook.Parent
Excel_Application.WindowState = xlMinimized
Excel_Application.Visible = True
Excel_Workbook.Windows(1).Visible = True
Excel_Workbook.Worksheets(1).Name = "Report Output"
Set Current_Worksheet = Excel_Workbook.Worksheets("Report Output")
Excel_Workbook.Worksheets("Report Output").Select
THE code here works if left here but not in it's own sub procedure.- 'CAll
Add_Comments'
Current_Worksheet.Range("B11").AddComment
Current_Worksheet.Range("B11").Comment.Visible = False
Current_Worksheet.Range("B11").Comment.Text Text:="trevorc:" & Chr(10) &
"test"
I was hoping to then add code to this sub procedure.
I'm having trouble getting my code to work using sub procedures in my vba
code, this only happens when i am interacting with excel. I've tried to copy
all the dims and defs from the calling procedure but to no avail at this time.
sample code below.
Dim strPath As String
Dim rst As DAO.Recordset
Dim Excel_Application As Excel.Application
Dim Excel_Workbook As Excel.Workbook
Dim Current_Worksheet As Excel.Worksheet
Dim Data_Range
Dim Worksheet_Name
Dim db As Database
Dim rs As Recordset
D_now = Format(Date, "dd-mm-yy") ' Formated to use as part of file name
gg = "C:\Employee Time Report " & D_now & ".xls"
Is_File= Len(Dir(gg))
If Is_File= 0 Then
Else
T_Msg = MsgBox("File already exists, Delete file and continue ?.",
vbYesNo, "")
If T_Msg = vbYes Then
Kill gg
Else
Exit Sub
End If
End If
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, "Report Output",
gg, True
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, "Comments", gg,
True
Set Excel_Workbook = GetObject(gg)
Set Excel_Application = Excel_Workbook.Parent
Excel_Application.WindowState = xlMinimized
Excel_Application.Visible = True
Excel_Workbook.Windows(1).Visible = True
Excel_Workbook.Worksheets(1).Name = "Report Output"
Set Current_Worksheet = Excel_Workbook.Worksheets("Report Output")
Excel_Workbook.Worksheets("Report Output").Select
THE code here works if left here but not in it's own sub procedure.- 'CAll
Add_Comments'
Current_Worksheet.Range("B11").AddComment
Current_Worksheet.Range("B11").Comment.Visible = False
Current_Worksheet.Range("B11").Comment.Text Text:="trevorc:" & Chr(10) &
"test"
I was hoping to then add code to this sub procedure.