Stop after Resume Code

adeel1
3StarLounger
Posts: 264
Joined: 04 Oct 2017, 15:47

Stop after Resume Code

Post by adeel1 »

Hi All

I have below code is there any way I can resume code when its stop

Issue is when its stop I must download some WBK from internal portal due to some time links down/Connectivity/net work issue files took longer or sometimes it’s not taken 10 sec

Its keep hard to adjust time for us.

Code: Select all

Sub Fin_D()

Dim wb As Workbook
Dim c As Long
c = 2
For Each wb In Workbooks
  If wb.Name = "Test File" Then c = c + 1
Next wb
MsgBox "Please Download " & c & " Number of  WBK"
'Application.Wait (Now + TimeValue("0:00:15"))

Stop
Data_Fill
End Sub
Sub Data_Fill()
'some action is here along with long code
End Sub

User avatar
HansV
Administrator
Posts: 78236
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Stop after Resume Code

Post by HansV »

Isn't the message box sufficient?

MsgBox "Please Download " & c & " Number of WBK" & vbCrLf & "Click OK for the macro to continue."
Best wishes,
Hans

adeel1
3StarLounger
Posts: 264
Joined: 04 Oct 2017, 15:47

Re: Stop after Resume Code

Post by adeel1 »

it will run complete code if I hit ok and files isn't downloaded if I don't hit ok then file isn't downloaded due to msgbox.
Adeel

User avatar
HansV
Administrator
Posts: 78236
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Stop after Resume Code

Post by HansV »

I don't understand. Do you download the file manually or using code?
Best wishes,
Hans

adeel1
3StarLounger
Posts: 264
Joined: 04 Oct 2017, 15:47

Re: Stop after Resume Code

Post by adeel1 »

manually(By clicking on button) for some our internal portal/API.

I have to stop code still files downloaded and open.

Adeel

User avatar
HansV
Administrator
Posts: 78236
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Stop after Resume Code

Post by HansV »

I'd download the file before running the macro.
Best wishes,
Hans

adeel1
3StarLounger
Posts: 264
Joined: 04 Oct 2017, 15:47

Re: Stop after Resume Code

Post by adeel1 »

it is possible to write another code and get final value for download those files.

actually I have limited knowledge of VBA(Functions) so may I thought that may function is available for this that i haven't know.

Adeel

User avatar
HansV
Administrator
Posts: 78236
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Stop after Resume Code

Post by HansV »

I don't understand your question, sorry.
Best wishes,
Hans

adeel1
3StarLounger
Posts: 264
Joined: 04 Oct 2017, 15:47

Re: Stop after Resume Code

Post by adeel1 »

Hello sir
let me rephrase
I just want to stop code when msgbox appear from first code and want to resume in some way when i want. is this possible

it should not run Data_Fill code until i resume.
Adeel

User avatar
HansV
Administrator
Posts: 78236
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Stop after Resume Code

Post by HansV »

But the code does pause when the message box is displayed, and it will only continue when the user has clicked OK. So you don't need to add anything else in the code.
Best wishes,
Hans

adeel1
3StarLounger
Posts: 264
Joined: 04 Oct 2017, 15:47

Re: Stop after Resume Code

Post by adeel1 »

yes it is, code does pause but there is some info on msgbox so user have to use some in house application to download those files which downloaded and open automatically.(these files will be downloaded from some other application not with excel or code)

due to msgbox those files are not open if user click ok on msgbox code turn into error.

one thing which I can use separate both code and make separate button in sheet but i am in search to avoid separate the codes.

Adeel

User avatar
HansV
Administrator
Posts: 78236
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Stop after Resume Code

Post by HansV »

I'm afraid that you will have to use two separate macros.
Best wishes,
Hans

adeel1
3StarLounger
Posts: 264
Joined: 04 Oct 2017, 15:47

Re: Stop after Resume Code

Post by adeel1 »

Indeed thnx for your help.
Adeel